[CMF-checkins] SVN: CMF/branches/1.6/CMFCore/exportimport/ backported r40877:40878 from trunk:

Yvo Schubbe y.2005- at wcm-solutions.de
Sun Dec 18 17:08:21 EST 2005


Log message for revision 40879:
  backported r40877:40878 from trunk:
  - updated tool export and import steps
  - minor cleanup
  

Changed:
  U   CMF/branches/1.6/CMFCore/exportimport/actions.py
  U   CMF/branches/1.6/CMFCore/exportimport/cachingpolicymgr.py
  U   CMF/branches/1.6/CMFCore/exportimport/catalog.py
  U   CMF/branches/1.6/CMFCore/exportimport/contenttyperegistry.py
  U   CMF/branches/1.6/CMFCore/exportimport/cookieauth.py
  U   CMF/branches/1.6/CMFCore/exportimport/mailhost.py
  U   CMF/branches/1.6/CMFCore/exportimport/skins.py
  U   CMF/branches/1.6/CMFCore/exportimport/tests/test_skins.py
  U   CMF/branches/1.6/CMFCore/exportimport/tests/test_workflow.py
  U   CMF/branches/1.6/CMFCore/exportimport/typeinfo.py
  U   CMF/branches/1.6/CMFCore/exportimport/workflow.py

-=-
Modified: CMF/branches/1.6/CMFCore/exportimport/actions.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/actions.py	2005-12-18 21:57:56 UTC (rev 40878)
+++ CMF/branches/1.6/CMFCore/exportimport/actions.py	2005-12-18 22:08:21 UTC (rev 40879)
@@ -15,9 +15,8 @@
 $Id: actions.py 39947 2005-11-06 16:41:15Z yuppie $
 """
 
-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 IActionProvider
@@ -26,7 +25,6 @@
         import ActionProvider as z2IActionProvider
 from Products.CMFCore.utils import getToolByName
 
-_FILENAME = 'actions.xml'
 
 
 class ActionsToolXMLAdapter(XMLAdapterBase):
@@ -38,6 +36,8 @@
 
     _LOGGER_ID = 'actions'
 
+    name = 'actions'
+
     def _exportNode(self):
         """Export the object as a DOM node.
         """
@@ -173,34 +173,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/branches/1.6/CMFCore/exportimport/cachingpolicymgr.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/cachingpolicymgr.py	2005-12-18 21:57:56 UTC (rev 40878)
+++ CMF/branches/1.6/CMFCore/exportimport/cachingpolicymgr.py	2005-12-18 22:08:21 UTC (rev 40879)
@@ -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/branches/1.6/CMFCore/exportimport/catalog.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/catalog.py	2005-12-18 21:57:56 UTC (rev 40878)
+++ CMF/branches/1.6/CMFCore/exportimport/catalog.py	2005-12-18 22:08:21 UTC (rev 40879)
@@ -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/branches/1.6/CMFCore/exportimport/contenttyperegistry.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/contenttyperegistry.py	2005-12-18 21:57:56 UTC (rev 40878)
+++ CMF/branches/1.6/CMFCore/exportimport/contenttyperegistry.py	2005-12-18 22:08:21 UTC (rev 40879)
@@ -15,17 +15,14 @@
 $Id: contenttyperegistry.py 40087 2005-11-13 19:55:09Z yuppie $
 """
 
-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/branches/1.6/CMFCore/exportimport/cookieauth.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/cookieauth.py	2005-12-18 21:57:56 UTC (rev 40878)
+++ CMF/branches/1.6/CMFCore/exportimport/cookieauth.py	2005-12-18 22:08:21 UTC (rev 40879)
@@ -15,18 +15,15 @@
 $Id: cookieauth.py 39493 2005-10-17 18:48:24Z yuppie $
 """
 
-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/branches/1.6/CMFCore/exportimport/mailhost.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/mailhost.py	2005-12-18 21:57:56 UTC (rev 40878)
+++ CMF/branches/1.6/CMFCore/exportimport/mailhost.py	2005-12-18 22:08:21 UTC (rev 40879)
@@ -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/branches/1.6/CMFCore/exportimport/skins.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/skins.py	2005-12-18 21:57:56 UTC (rev 40878)
+++ CMF/branches/1.6/CMFCore/exportimport/skins.py	2005-12-18 22:08:21 UTC (rev 40879)
@@ -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/branches/1.6/CMFCore/exportimport/tests/test_skins.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/tests/test_skins.py	2005-12-18 21:57:56 UTC (rev 40878)
+++ CMF/branches/1.6/CMFCore/exportimport/tests/test_skins.py	2005-12-18 22:08:21 UTC (rev 40879)
@@ -625,7 +625,7 @@
         unittest.makeSuite(exportSkinsToolTests),
         unittest.makeSuite(importSkinsToolTests),
         unittest.makeSuite(importSkinsToolV1Tests),
-       ))
+        ))
 
 if __name__ == '__main__':
     unittest.main(defaultTest='test_suite')

Modified: CMF/branches/1.6/CMFCore/exportimport/tests/test_workflow.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/tests/test_workflow.py	2005-12-18 21:57:56 UTC (rev 40878)
+++ CMF/branches/1.6/CMFCore/exportimport/tests/test_workflow.py	2005-12-18 22:08:21 UTC (rev 40879)
@@ -401,7 +401,7 @@
         unittest.makeSuite(exportWorkflowToolTests),
         unittest.makeSuite(importWorkflowToolTests),
         unittest.makeSuite(importWorkflowToolV1Tests),
-       ))
+        ))
 
 if __name__ == '__main__':
     unittest.main(defaultTest='test_suite')

Modified: CMF/branches/1.6/CMFCore/exportimport/typeinfo.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/typeinfo.py	2005-12-18 21:57:56 UTC (rev 40878)
+++ CMF/branches/1.6/CMFCore/exportimport/typeinfo.py	2005-12-18 22:08:21 UTC (rev 40879)
@@ -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/branches/1.6/CMFCore/exportimport/workflow.py
===================================================================
--- CMF/branches/1.6/CMFCore/exportimport/workflow.py	2005-12-18 21:57:56 UTC (rev 40878)
+++ CMF/branches/1.6/CMFCore/exportimport/workflow.py	2005-12-18 22:08:21 UTC (rev 40879)
@@ -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)



More information about the CMF-checkins mailing list