[CMF-checkins] SVN: CMF/trunk/ - added name property to IBody

Yvo Schubbe y.2005- at wcm-solutions.de
Sun Dec 18 16:57:57 EST 2005


Log message for revision 40878:
  - added name property to IBody
  - improved utils exportObjects() and importObjects() to handle a bigger part of tool export and import steps
  - updated tool export and import steps
  
  Note: exportObjects() and importObjects() are modified in a non-backwards compatible way

Changed:
  U   CMF/trunk/CMFCore/exportimport/actions.py
  U   CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py
  U   CMF/trunk/CMFCore/exportimport/catalog.py
  U   CMF/trunk/CMFCore/exportimport/contenttyperegistry.py
  U   CMF/trunk/CMFCore/exportimport/cookieauth.py
  U   CMF/trunk/CMFCore/exportimport/mailhost.py
  U   CMF/trunk/CMFCore/exportimport/skins.py
  U   CMF/trunk/CMFCore/exportimport/typeinfo.py
  U   CMF/trunk/CMFCore/exportimport/workflow.py
  U   CMF/trunk/GenericSetup/MailHost/exportimport.py
  U   CMF/trunk/GenericSetup/ZCatalog/exportimport.py
  U   CMF/trunk/GenericSetup/interfaces.py
  U   CMF/trunk/GenericSetup/utils.py

-=-
Modified: CMF/trunk/CMFCore/exportimport/actions.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/actions.py	2005-12-18 21:38:25 UTC (rev 40877)
+++ CMF/trunk/CMFCore/exportimport/actions.py	2005-12-18 21:57:56 UTC (rev 40878)
@@ -15,10 +15,9 @@
 $Id$
 """
 
-from zope.app import zapi
-
-from Products.GenericSetup.interfaces import IBody
+from Products.GenericSetup.utils import exportObjects
 from Products.GenericSetup.utils import I18NURI
+from Products.GenericSetup.utils import importObjects
 from Products.GenericSetup.utils import NodeAdapterBase
 from Products.GenericSetup.utils import ObjectManagerHelpers
 from Products.GenericSetup.utils import PropertyManagerHelpers
@@ -32,7 +31,6 @@
         import ActionProvider as z2IActionProvider
 from Products.CMFCore.utils import getToolByName
 
-_FILENAME = 'actions.xml'
 _SPECIAL_PROVIDERS = ('portal_actions', 'portal_types', 'portal_workflow')
 
 
@@ -105,6 +103,8 @@
 
     _LOGGER_ID = 'actions'
 
+    name = 'actions'
+
     def _exportNode(self):
         """Export the object as a DOM node.
         """
@@ -247,34 +247,18 @@
     """Import actions tool.
     """
     site = context.getSite()
-    logger = context.getLogger('actions')
     tool = getToolByName(site, 'portal_actions')
 
-    body = context.readDataFile(_FILENAME)
-    if body is None:
-        logger.info('Nothing to import.')
-        return
+    importObjects(tool, '', context)
 
-    importer = zapi.queryMultiAdapter((tool, context), IBody)
-    if importer is None:
-        logger.warning('Import adapter misssing.')
-        return
-
-    importer.body = body
-
 def exportActionProviders(context):
     """Export actions tool.
     """
     site = context.getSite()
-    logger = context.getLogger('actions')
     tool = getToolByName(site, 'portal_actions', None)
     if tool is None:
+        logger = context.getLogger('actions')
         logger.info('Nothing to export.')
         return
 
-    exporter = zapi.queryMultiAdapter((tool, context), IBody)
-    if exporter is None:
-        logger.warning('Export adapter misssing.')
-        return
-
-    context.writeDataFile(_FILENAME, exporter.body, exporter.mime_type)
+    exportObjects(tool, '', context)

Modified: CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py	2005-12-18 21:38:25 UTC (rev 40877)
+++ CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py	2005-12-18 21:57:56 UTC (rev 40878)
@@ -17,7 +17,8 @@
 
 from zope.app import zapi
 
-from Products.GenericSetup.interfaces import IBody
+from Products.GenericSetup.utils import exportObjects
+from Products.GenericSetup.utils import importObjects
 from Products.GenericSetup.interfaces import INode
 from Products.GenericSetup.utils import NodeAdapterBase
 from Products.GenericSetup.utils import XMLAdapterBase
@@ -26,9 +27,7 @@
 from Products.CMFCore.interfaces import ICachingPolicyManager
 from Products.CMFCore.utils import getToolByName
 
-_FILENAME = 'cachingpolicymgr.xml'
 
-
 class CachingPolicyNodeAdapter(NodeAdapterBase):
 
     """Node im- and exporter for CachingPolicy.
@@ -122,6 +121,8 @@
 
     _LOGGER_ID = 'cachingpolicies'
 
+    name = 'cachingpolicymgr'
+
     def _exportNode(self):
         """Export the object as a DOM node.
         """
@@ -173,34 +174,18 @@
     """Import caching policy manager settings from an XML file.
     """
     site = context.getSite()
-    logger = context.getLogger('cachingpolicies')
     tool = getToolByName(site, 'caching_policy_manager')
 
-    body = context.readDataFile(_FILENAME)
-    if body is None:
-        logger.info('Nothing to import.')
-        return
+    importObjects(tool, '', context)
 
-    importer = zapi.queryMultiAdapter((tool, context), IBody)
-    if importer is None:
-        logger.warning('Import adapter misssing.')
-        return
-
-    importer.body = body
-
 def exportCachingPolicyManager(context):
     """Export caching policy manager settings as an XML file.
     """
     site = context.getSite()
-    logger = context.getLogger('cachingpolicies')
     tool = getToolByName(site, 'caching_policy_manager', None)
     if tool is None:
+        logger = context.getLogger('cachingpolicies')
         logger.info('Nothing to export.')
         return
 
-    exporter = zapi.queryMultiAdapter((tool, context), IBody)
-    if exporter is None:
-        logger.warning('Export adapter misssing.')
-        return
-
-    context.writeDataFile(_FILENAME, exporter.body, exporter.mime_type)
+    exportObjects(tool, '', context)

Modified: CMF/trunk/CMFCore/exportimport/catalog.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/catalog.py	2005-12-18 21:38:25 UTC (rev 40877)
+++ CMF/trunk/CMFCore/exportimport/catalog.py	2005-12-18 21:57:56 UTC (rev 40878)
@@ -15,47 +15,28 @@
 $Id$
 """
 
-from zope.app import zapi
+from Products.GenericSetup.utils import exportObjects
+from Products.GenericSetup.utils import importObjects
 
-from Products.GenericSetup.interfaces import IBody
-
 from Products.CMFCore.utils import getToolByName
 
-_FILENAME = 'catalog.xml'
 
-
 def importCatalogTool(context):
     """Import catalog tool.
     """
     site = context.getSite()
-    logger = context.getLogger('catalog')
     tool = getToolByName(site, 'portal_catalog')
 
-    body = context.readDataFile(_FILENAME)
-    if body is None:
-        logger.info('Nothing to import.')
-        return
+    importObjects(tool, '', context)
 
-    importer = zapi.queryMultiAdapter((tool, context), IBody)
-    if importer is None:
-        logger.warning('Import adapter misssing.')
-        return
-
-    importer.body = body
-
 def exportCatalogTool(context):
     """Export catalog tool.
     """
     site = context.getSite()
-    logger = context.getLogger('catalog')
     tool = getToolByName(site, 'portal_catalog', None)
     if tool is None:
+        logger = context.getLogger('catalog')
         logger.info('Nothing to export.')
         return
 
-    exporter = zapi.queryMultiAdapter((tool, context), IBody)
-    if exporter is None:
-        logger.warning('Export adapter misssing.')
-        return
-
-    context.writeDataFile(_FILENAME, exporter.body, exporter.mime_type)
+    exportObjects(tool, '', context)

Modified: CMF/trunk/CMFCore/exportimport/contenttyperegistry.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/contenttyperegistry.py	2005-12-18 21:38:25 UTC (rev 40877)
+++ CMF/trunk/CMFCore/exportimport/contenttyperegistry.py	2005-12-18 21:57:56 UTC (rev 40878)
@@ -15,17 +15,14 @@
 $Id$
 """
 
-from zope.app import zapi
-
-from Products.GenericSetup.interfaces import IBody
+from Products.GenericSetup.utils import exportObjects
+from Products.GenericSetup.utils import importObjects
 from Products.GenericSetup.utils import XMLAdapterBase
 
 from Products.CMFCore.interfaces import IContentTypeRegistry
 from Products.CMFCore.utils import getToolByName
 
-_FILENAME = 'contenttyperegistry.xml'
 
-
 class ContentTypeRegistryXMLAdapter(XMLAdapterBase):
 
     """XML im- and exporter for ContentTypeRegistry.
@@ -35,6 +32,8 @@
 
     _LOGGER_ID = 'contenttypes'
 
+    name = 'contenttyperegistry'
+
     def _exportNode(self):
         """Export the object as a DOM node.
         """
@@ -113,34 +112,18 @@
     """Import content type registry settings from an XML file.
     """
     site = context.getSite()
-    logger = context.getLogger('contenttypes')
     tool = getToolByName(site, 'content_type_registry')
 
-    body = context.readDataFile(_FILENAME)
-    if body is None:
-        logger.info('Nothing to import.')
-        return
+    importObjects(tool, '', context)
 
-    importer = zapi.queryMultiAdapter((tool, context), IBody)
-    if importer is None:
-        logger.warning('Import adapter misssing.')
-        return
-
-    importer.body = body
-
 def exportContentTypeRegistry(context):
     """Export content type registry settings as an XML file.
     """
     site = context.getSite()
-    logger = context.getLogger('contenttypes')
     tool = getToolByName(site, 'content_type_registry', None)
     if tool is None:
+        logger = context.getLogger('contenttypes')
         logger.info('Nothing to export.')
         return
 
-    exporter = zapi.queryMultiAdapter((tool, context), IBody)
-    if exporter is None:
-        logger.warning('Export adapter misssing.')
-        return
-
-    context.writeDataFile(_FILENAME, exporter.body, exporter.mime_type)
+    exportObjects(tool, '', context)

Modified: CMF/trunk/CMFCore/exportimport/cookieauth.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/cookieauth.py	2005-12-18 21:38:25 UTC (rev 40877)
+++ CMF/trunk/CMFCore/exportimport/cookieauth.py	2005-12-18 21:57:56 UTC (rev 40878)
@@ -15,18 +15,15 @@
 $Id$
 """
 
-from zope.app import zapi
-
-from Products.GenericSetup.interfaces import IBody
+from Products.GenericSetup.utils import exportObjects
+from Products.GenericSetup.utils import importObjects
 from Products.GenericSetup.utils import PropertyManagerHelpers
 from Products.GenericSetup.utils import XMLAdapterBase
 
 from Products.CMFCore.interfaces import ICookieCrumbler
 from Products.CMFCore.utils import getToolByName
 
-_FILENAME = 'cookieauth.xml'
 
-
 class CookieCrumblerXMLAdapter(XMLAdapterBase, PropertyManagerHelpers):
 
     """XML im- and exporter for CookieCrumbler.
@@ -36,6 +33,8 @@
 
     _LOGGER_ID = 'cookies'
 
+    name = 'cookieauth'
+
     def _exportNode(self):
         """Export the object as a DOM node.
         """
@@ -60,34 +59,18 @@
     """Import cookie crumbler settings from an XML file.
     """
     site = context.getSite()
-    logger = context.getLogger('cookies')
     tool = getToolByName(site, 'cookie_authentication')
 
-    body = context.readDataFile(_FILENAME)
-    if body is None:
-        logger.info('Nothing to import.')
-        return
+    importObjects(tool, '', context)
 
-    importer = zapi.queryMultiAdapter((tool, context), IBody)
-    if importer is None:
-        logger.warning('Import adapter misssing.')
-        return
-
-    importer.body = body
-
 def exportCookieCrumbler(context):
     """Export cookie crumbler settings as an XML file.
     """
     site = context.getSite()
-    logger = context.getLogger('cookies')
     tool = getToolByName(site, 'cookie_authentication', None)
     if tool is None:
+        logger = context.getLogger('cookies')
         logger.info('Nothing to export.')
         return
 
-    exporter = zapi.queryMultiAdapter((tool, context), IBody)
-    if exporter is None:
-        logger.warning('Export adapter misssing.')
-        return
-
-    context.writeDataFile(_FILENAME, exporter.body, exporter.mime_type)
+    exportObjects(tool, '', context)

Modified: CMF/trunk/CMFCore/exportimport/mailhost.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/mailhost.py	2005-12-18 21:38:25 UTC (rev 40877)
+++ CMF/trunk/CMFCore/exportimport/mailhost.py	2005-12-18 21:57:56 UTC (rev 40878)
@@ -15,47 +15,28 @@
 $Id$
 """
 
-from zope.app import zapi
+from Products.GenericSetup.utils import exportObjects
+from Products.GenericSetup.utils import importObjects
 
-from Products.GenericSetup.interfaces import IBody
-
 from Products.CMFCore.utils import getToolByName
 
-_FILENAME = 'mailhost.xml'
 
-
 def importMailHost(context):
     """Import mailhost settings from an XML file.
     """
     site = context.getSite()
-    logger = context.getLogger('mailhost')
     tool = getToolByName(site, 'MailHost')
 
-    body = context.readDataFile(_FILENAME)
-    if body is None:
-        logger.info('Nothing to import.')
-        return
+    importObjects(tool, '', context)
 
-    importer = zapi.queryMultiAdapter((tool, context), IBody)
-    if importer is None:
-        logger.warning('Import adapter misssing.')
-        return
-
-    importer.body = body
-
 def exportMailHost(context):
     """Export mailhost settings as an XML file.
     """
     site = context.getSite()
-    logger = context.getLogger('mailhost')
     tool = getToolByName(site, 'MailHost', None)
     if tool is None:
+        logger = context.getLogger('mailhost')
         logger.info('Nothing to export.')
         return
 
-    exporter = zapi.queryMultiAdapter((tool, context), IBody)
-    if exporter is None:
-        logger.warning('Export adapter misssing.')
-        return
-
-    context.writeDataFile(_FILENAME, exporter.body, exporter.mime_type)
+    exportObjects(tool, '', context)

Modified: CMF/trunk/CMFCore/exportimport/skins.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/skins.py	2005-12-18 21:38:25 UTC (rev 40877)
+++ CMF/trunk/CMFCore/exportimport/skins.py	2005-12-18 21:57:56 UTC (rev 40878)
@@ -17,9 +17,7 @@
 
 from Acquisition import aq_inner
 from Acquisition import aq_parent
-from zope.app import zapi
 
-from Products.GenericSetup.interfaces import IBody
 from Products.GenericSetup.utils import exportObjects
 from Products.GenericSetup.utils import importObjects
 from Products.GenericSetup.utils import NodeAdapterBase
@@ -31,9 +29,7 @@
 from Products.CMFCore.interfaces import ISkinsTool
 from Products.CMFCore.utils import getToolByName
 
-_FILENAME = 'skins.xml'
 
-
 class DirectoryViewNodeAdapter(NodeAdapterBase):
 
     """Node im- and exporter for DirectoryView.
@@ -65,6 +61,8 @@
 
     _LOGGER_ID = 'skins'
 
+    name = 'skins'
+
     def _exportNode(self):
         """Export the object as a DOM node.
         """
@@ -208,36 +206,18 @@
     """Import skins tool FSDirViews and skin paths from an XML file.
     """
     site = context.getSite()
-    logger = context.getLogger('skins')
     tool = getToolByName(site, 'portal_skins')
 
-    body = context.readDataFile(_FILENAME)
-    if body is None:
-        logger.info('Nothing to import.')
-        return
+    importObjects(tool, '', context)
 
-    importer = zapi.queryMultiAdapter((tool, context), IBody)
-    if importer is None:
-        logger.warning('Import adapter misssing.')
-        return
-
-    importer.body = body
-    importObjects(tool, 'skins', context)
-
 def exportSkinsTool(context):
     """Export skins tool FSDVs and skin paths as an XML file.
     """
     site = context.getSite()
-    logger = context.getLogger('skins')
     tool = getToolByName(site, 'portal_skins', None)
     if tool is None:
+        logger = context.getLogger('skins')
         logger.info('Nothing to export.')
         return
 
-    exporter = zapi.queryMultiAdapter((tool, context), IBody)
-    if exporter is None:
-        logger.warning('Export adapter misssing.')
-        return
-
-    context.writeDataFile(_FILENAME, exporter.body, exporter.mime_type)
-    exportObjects(tool, 'skins', context)
+    exportObjects(tool, '', context)

Modified: CMF/trunk/CMFCore/exportimport/typeinfo.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/typeinfo.py	2005-12-18 21:38:25 UTC (rev 40877)
+++ CMF/trunk/CMFCore/exportimport/typeinfo.py	2005-12-18 21:57:56 UTC (rev 40878)
@@ -18,9 +18,7 @@
 from xml.dom.minidom import parseString
 
 import Products
-from zope.app import zapi
 
-from Products.GenericSetup.interfaces import IBody
 from Products.GenericSetup.utils import exportObjects
 from Products.GenericSetup.utils import I18NURI
 from Products.GenericSetup.utils import importObjects
@@ -32,9 +30,7 @@
 from Products.CMFCore.interfaces import ITypesTool
 from Products.CMFCore.utils import getToolByName
 
-_FILENAME = 'types.xml'
 
-
 class TypeInformationXMLAdapter(XMLAdapterBase, PropertyManagerHelpers):
 
     """XML im- and exporter for TypeInformation.
@@ -209,6 +205,8 @@
 
     _LOGGER_ID = 'types'
 
+    name = 'types'
+
     def _exportNode(self):
         """Export the object as a DOM node.
         """
@@ -264,38 +262,18 @@
     """Import types tool and content types from XML files.
     """
     site = context.getSite()
-    logger = context.getLogger('types')
     tool = getToolByName(site, 'portal_types')
 
-    body = context.readDataFile(_FILENAME)
-    if body is None:
-        body = context.readDataFile('typestool.xml')
-        if body is None:
-            logger.info('Nothing to import.')
-            return
+    importObjects(tool, '', context)
 
-    importer = zapi.queryMultiAdapter((tool, context), IBody)
-    if importer is None:
-        logger.warning('Import adapter misssing.')
-        return
-
-    importer.body = body
-    importObjects(tool, 'types', context)
-
 def exportTypesTool(context):
     """Export types tool content types as a set of XML files.
     """
     site = context.getSite()
-    logger = context.getLogger('types')
     tool = getToolByName(site, 'portal_types', None)
     if tool is None:
+        logger = context.getLogger('types')
         logger.info('Nothing to export.')
         return
 
-    exporter = zapi.queryMultiAdapter((tool, context), IBody)
-    if exporter is None:
-        logger.warning('Export adapter misssing.')
-        return
-
-    context.writeDataFile(_FILENAME, exporter.body, exporter.mime_type)
-    exportObjects(tool, 'types', context)
+    exportObjects(tool, '', context)

Modified: CMF/trunk/CMFCore/exportimport/workflow.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/workflow.py	2005-12-18 21:38:25 UTC (rev 40877)
+++ CMF/trunk/CMFCore/exportimport/workflow.py	2005-12-18 21:57:56 UTC (rev 40878)
@@ -16,9 +16,7 @@
 """
 
 import Products
-from zope.app import zapi
 
-from Products.GenericSetup.interfaces import IBody
 from Products.GenericSetup.utils import exportObjects
 from Products.GenericSetup.utils import importObjects
 from Products.GenericSetup.utils import ObjectManagerHelpers
@@ -28,9 +26,7 @@
 from Products.CMFCore.interfaces import IWorkflowTool
 from Products.CMFCore.utils import getToolByName
 
-_FILENAME = 'workflows.xml'
 
-
 class WorkflowToolXMLAdapter(XMLAdapterBase, ObjectManagerHelpers,
                              PropertyManagerHelpers):
 
@@ -41,6 +37,8 @@
 
     _LOGGER_ID = 'workflow'
 
+    name = 'workflows'
+
     def _exportNode(self):
         """Export the object as a DOM node.
         """
@@ -136,36 +134,18 @@
     """Import workflow tool and contained workflow definitions from XML files.
     """
     site = context.getSite()
-    logger = context.getLogger('workflow')
     tool = getToolByName(site, 'portal_workflow')
 
-    body = context.readDataFile(_FILENAME)
-    if body is None:
-        logger.info('Nothing to import.')
-        return
+    importObjects(tool, '', context)
 
-    importer = zapi.queryMultiAdapter((tool, context), IBody)
-    if importer is None:
-        logger.warning('Import adapter misssing.')
-        return
-
-    importer.body = body
-    importObjects(tool, 'workflows', context)
-
 def exportWorkflowTool(context):
     """Export workflow tool and contained workflow definitions as XML files.
     """
     site = context.getSite()
-    logger = context.getLogger('workflow')
-    tool = getToolByName(site, 'portal_workflow')
+    tool = getToolByName(site, 'portal_workflow', None)
     if tool is None:
+        logger = context.getLogger('workflow')
         logger.info('Nothing to export.')
         return
 
-    exporter = zapi.queryMultiAdapter((tool, context), IBody)
-    if exporter is None:
-        logger.warning('Export adapter misssing.')
-        return
-
-    context.writeDataFile(_FILENAME, exporter.body, exporter.mime_type)
-    exportObjects(tool, 'workflows', context)
+    exportObjects(tool, '', context)

Modified: CMF/trunk/GenericSetup/MailHost/exportimport.py
===================================================================
--- CMF/trunk/GenericSetup/MailHost/exportimport.py	2005-12-18 21:38:25 UTC (rev 40877)
+++ CMF/trunk/GenericSetup/MailHost/exportimport.py	2005-12-18 21:57:56 UTC (rev 40878)
@@ -29,6 +29,8 @@
 
     _LOGGER_ID = 'mailhost'
 
+    name = 'mailhost'
+
     def _exportNode(self):
         """Export the object as a DOM node.
         """

Modified: CMF/trunk/GenericSetup/ZCatalog/exportimport.py
===================================================================
--- CMF/trunk/GenericSetup/ZCatalog/exportimport.py	2005-12-18 21:38:25 UTC (rev 40877)
+++ CMF/trunk/GenericSetup/ZCatalog/exportimport.py	2005-12-18 21:57:56 UTC (rev 40878)
@@ -40,6 +40,8 @@
 
     _LOGGER_ID = 'catalog'
 
+    name = 'catalog'
+
     def _exportNode(self):
         """Export the object as a DOM node.
         """

Modified: CMF/trunk/GenericSetup/interfaces.py
===================================================================
--- CMF/trunk/GenericSetup/interfaces.py	2005-12-18 21:38:25 UTC (rev 40877)
+++ CMF/trunk/GenericSetup/interfaces.py	2005-12-18 21:57:56 UTC (rev 40878)
@@ -611,6 +611,8 @@
 
     mime_type = TextLine(description=u'MIME type of the file body.')
 
+    name = TextLine(description=u'Enforce this name for the file.')
+
     suffix = TextLine(description=u'Suffix for the file.')
 
 

Modified: CMF/trunk/GenericSetup/utils.py
===================================================================
--- CMF/trunk/GenericSetup/utils.py	2005-12-18 21:38:25 UTC (rev 40877)
+++ CMF/trunk/GenericSetup/utils.py	2005-12-18 21:57:56 UTC (rev 40878)
@@ -477,6 +477,8 @@
 
     mime_type = 'text/plain'
 
+    name = ''
+
     suffix = ''
 
 
@@ -502,6 +504,8 @@
 
     mime_type = 'text/xml'
 
+    name = ''
+
     suffix = '.xml'
 
 
@@ -663,34 +667,39 @@
             obj._updateProperty(prop_id, prop_value)
 
 
-def exportObjects(parent, parent_path, context):
+def exportObjects(obj, parent_path, context):
     """ Export subobjects recursively.
     """
-    for obj in parent.objectValues():
-        path = '%s/%s' % (parent_path, obj.getId().replace(' ', '_'))
+    exporter = zapi.queryMultiAdapter((obj, context), IBody)
+    path = '%s%s' % (parent_path, obj.getId().replace(' ', '_'))
+    if exporter:
+        if exporter.name:
+            path = '%s%s' % (parent_path, exporter.name)
+        filename = '%s%s' % (path, exporter.suffix)
+        body = exporter.body
+        if body is not None:
+            context.writeDataFile(filename, body, exporter.mime_type)
 
-        exporter = zapi.queryMultiAdapter((obj, context), IBody)
-        if exporter:
-            filename = '%s%s' % (path, exporter.suffix)
-            body = exporter.body
-            if body is not None:
-                context.writeDataFile(filename, body, exporter.mime_type)
+    if getattr(obj, 'objectValues', False):
+        for sub in obj.objectValues():
+            exportObjects(sub, path+'/', context)
 
-        if getattr(obj, 'objectValues', False):
-            exportObjects(obj, path, context)
-
-def importObjects(parent, parent_path, context):
+def importObjects(obj, parent_path, context):
     """ Import subobjects recursively.
     """
-    for obj in parent.objectValues():
-        path = '%s/%s' % (parent_path, obj.getId().replace(' ', '_'))
+    importer = zapi.queryMultiAdapter((obj, context), IBody)
+    path = '%s%s' % (parent_path, obj.getId().replace(' ', '_'))
+    if importer:
+        if importer.name:
+            path = '%s%s' % (parent_path, importer.name)
+        filename = '%s%s' % (path, importer.suffix)
+        body = context.readDataFile(filename)
+        if body is None and filename == 'types.xml':
+            # BBB: for CMF 1.5 profiles
+            body = context.readDataFile('typestool.xml')
+        if body is not None:
+            importer.body = body
 
-        importer = zapi.queryMultiAdapter((obj, context), IBody)
-        if importer:
-            filename = '%s%s' % (path, importer.suffix)
-            body = context.readDataFile(filename)
-            if body is not None:
-                importer.body = body
-
-        if getattr(obj, 'objectValues', False):
-            importObjects(obj, path, context)
+    if getattr(obj, 'objectValues', False):
+        for sub in obj.objectValues():
+            importObjects(sub, path+'/', context)



More information about the CMF-checkins mailing list