Back to index

plone3  3.1.7
exportimport.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2006 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """SampleSite setup handlers.
00014 
00015 $Id: exportimport.py 68596 2006-06-12 08:46:53Z yuppie $
00016 """
00017 
00018 from zope.component import queryMultiAdapter
00019 
00020 from Products.GenericSetup.interfaces import IBody
00021 from Products.GenericSetup.interfaces import ISetupTool
00022 from Products.GenericSetup.utils import exportObjects
00023 from Products.GenericSetup.utils import importObjects
00024 
00025 _PATH = 'siteroot'
00026 
00027 
00028 def importSite(context):
00029     """Import site configuration.
00030     """
00031     site = context.getSite()
00032     importer = queryMultiAdapter((site, context), IBody)
00033     if importer:
00034         body = context.readDataFile(_PATH+'.xml')
00035         if body is not None:
00036             importer.body = body
00037 
00038     for sub in site.objectValues():
00039         if ISetupTool.providedBy(sub):
00040             continue
00041         importObjects(sub, _PATH+'/', context)
00042 
00043 def exportSite(context):
00044     """Export site configuration.
00045     """
00046     site = context.getSite()
00047     exporter = queryMultiAdapter((site, context), IBody)
00048     if exporter:
00049         body = exporter.body
00050         if body is not None:
00051             context.writeDataFile(_PATH+'.xml', body, exporter.mime_type)
00052 
00053     for sub in site.objectValues():
00054         if ISetupTool.providedBy(sub):
00055             continue
00056         exportObjects(sub, _PATH+'/', context)