[CMF-checkins] SVN: CMF/trunk/ - moved setup handlers from CMFSetup
to CMFCore/exportimport
Yvo Schubbe
y.2005- at wcm-solutions.de
Tue Nov 29 14:44:07 EST 2005
Log message for revision 40413:
- moved setup handlers from CMFSetup to CMFCore/exportimport
- converted top level adapters from node to xml adapters
Changed:
U CMF/trunk/CMFActionIcons/exportimport.py
U CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py
A CMF/trunk/CMFCore/exportimport/catalog.py
U CMF/trunk/CMFCore/exportimport/configure.zcml
U CMF/trunk/CMFCore/exportimport/contenttyperegistry.py
U CMF/trunk/CMFCore/exportimport/cookieauth.py
A CMF/trunk/CMFCore/exportimport/mailhost.py
U CMF/trunk/CMFCore/exportimport/properties.py
U CMF/trunk/CMFCore/exportimport/skins.py
U CMF/trunk/CMFCore/exportimport/tests/test_actions.py
U CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py
A CMF/trunk/CMFCore/exportimport/tests/test_catalog.py
U CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py
U CMF/trunk/CMFCore/exportimport/tests/test_cookieauth.py
A CMF/trunk/CMFCore/exportimport/tests/test_mailhost.py
U CMF/trunk/CMFCore/exportimport/tests/test_properties.py
U CMF/trunk/CMFCore/exportimport/tests/test_skins.py
U CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py
U CMF/trunk/CMFCore/exportimport/tests/test_workflow.py
U CMF/trunk/CMFCore/exportimport/typeinfo.py
U CMF/trunk/CMFDefault/profiles/default/export_steps.xml
U CMF/trunk/CMFDefault/profiles/default/import_steps.xml
U CMF/trunk/CMFSetup/cachingpolicymgr.py
U CMF/trunk/CMFSetup/catalog.py
U CMF/trunk/CMFSetup/contenttyperegistry.py
U CMF/trunk/CMFSetup/cookieauth.py
U CMF/trunk/CMFSetup/mailhost.py
U CMF/trunk/CMFSetup/properties.py
D CMF/trunk/CMFSetup/tests/test_cachingpolicymgr.py
D CMF/trunk/CMFSetup/tests/test_catalog.py
D CMF/trunk/CMFSetup/tests/test_contenttyperegistry.py
D CMF/trunk/CMFSetup/tests/test_cookieauth.py
D CMF/trunk/CMFSetup/tests/test_mailhost.py
D CMF/trunk/CMFSetup/tests/test_properties.py
U CMF/trunk/GenericSetup/MailHost/configure.zcml
U CMF/trunk/GenericSetup/MailHost/exportimport.py
U CMF/trunk/GenericSetup/MailHost/tests/test_exportimport.py
U CMF/trunk/GenericSetup/OFSP/exportimport.py
U CMF/trunk/GenericSetup/ZCatalog/configure.zcml
U CMF/trunk/GenericSetup/ZCatalog/exportimport.py
U CMF/trunk/GenericSetup/ZCatalog/tests/test_exportimport.py
-=-
Modified: CMF/trunk/CMFActionIcons/exportimport.py
===================================================================
--- CMF/trunk/CMFActionIcons/exportimport.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFActionIcons/exportimport.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -24,11 +24,11 @@
from Products.CMFCore.utils import getToolByName
-from Products.CMFSetup.utils import CONVERTER
-from Products.CMFSetup.utils import DEFAULT
-from Products.CMFSetup.utils import ExportConfiguratorBase
-from Products.CMFSetup.utils import ImportConfiguratorBase
-from Products.CMFSetup.utils import KEY
+from Products.GenericSetup.utils import CONVERTER
+from Products.GenericSetup.utils import DEFAULT
+from Products.GenericSetup.utils import ExportConfiguratorBase
+from Products.GenericSetup.utils import ImportConfiguratorBase
+from Products.GenericSetup.utils import KEY
from permissions import ManagePortal
@@ -75,6 +75,7 @@
return 'Action icons tool settings exported.'
+
class ActionIconsToolExportConfigurator(ExportConfiguratorBase):
""" Synthesize XML description of cc properties.
"""
@@ -100,6 +101,7 @@
InitializeClass(ActionIconsToolExportConfigurator)
+
class ActionIconsToolImportConfigurator(ImportConfiguratorBase):
def _getImportMapping(self):
@@ -115,4 +117,7 @@
},
}
+ def _convertToInteger(self, val):
+ return int(val.strip())
+
InitializeClass(ActionIconsToolImportConfigurator)
Modified: CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -10,20 +10,27 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Caching policy manager node adapters.
+"""Caching policy manager xml adapters and setup handlers.
$Id$
"""
+from zope.app import zapi
+
+from Products.GenericSetup.interfaces import IBody
from Products.GenericSetup.interfaces import INodeExporter
from Products.GenericSetup.interfaces import INodeImporter
from Products.GenericSetup.interfaces import PURGE
from Products.GenericSetup.utils import NodeAdapterBase
+from Products.GenericSetup.utils import XMLAdapterBase
from Products.CMFCore.interfaces import ICachingPolicy
from Products.CMFCore.interfaces import ICachingPolicyManager
+from Products.CMFCore.utils import getToolByName
+_FILENAME = 'cachingpolicymgr.xml'
+
class CachingPolicyNodeAdapter(NodeAdapterBase):
"""Node im- and exporter for CachingPolicy.
@@ -107,19 +114,23 @@
self.context.__init__(**info)
-class CachingPolicyManagerNodeAdapter(NodeAdapterBase):
+class CachingPolicyManagerXMLAdapter(XMLAdapterBase):
- """Node im- and exporter for CachingPolicyManager.
+ """XML im- and exporter for CachingPolicyManager.
"""
__used_for__ = ICachingPolicyManager
+ _LOGGER_ID = 'cachingpolicies'
+
def exportNode(self, doc):
"""Export the object as a DOM node.
"""
self._doc = doc
node = self._getObjectNode('object')
node.appendChild(self._extractCachingPolicies())
+
+ self._logger.info('Caching policy manager exported.')
return node
def importNode(self, node, mode=PURGE):
@@ -130,6 +141,8 @@
self._initCachingPolicies(node, mode)
+ self._logger.info('Caching policy manager imported.')
+
def _extractCachingPolicies(self):
fragment = self._doc.createDocumentFragment()
for policy_id, policy in self.context.listPolicies():
@@ -155,3 +168,40 @@
policy = self.context._policies[policy_id]
INodeImporter(policy).importNode(child, mode)
+
+
+def importCachingPolicyManager(context):
+ """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
+
+ 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.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)
Copied: CMF/trunk/CMFCore/exportimport/catalog.py (from rev 40391, CMF/trunk/CMFSetup/catalog.py)
===================================================================
--- CMF/trunk/CMFSetup/catalog.py 2005-11-28 16:21:21 UTC (rev 40391)
+++ CMF/trunk/CMFCore/exportimport/catalog.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -0,0 +1,61 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Catalog tool setup handlers.
+
+$Id$
+"""
+
+from zope.app import zapi
+
+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
+
+ 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.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)
Modified: CMF/trunk/CMFCore/exportimport/configure.zcml
===================================================================
--- CMF/trunk/CMFCore/exportimport/configure.zcml 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/configure.zcml 2005-11-29 19:44:07 UTC (rev 40413)
@@ -46,18 +46,13 @@
/>
<adapter
- factory=".cachingpolicymgr.CachingPolicyManagerNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeExporter"
- for="Products.CMFCore.interfaces.ICachingPolicyManager"
+ factory=".cachingpolicymgr.CachingPolicyManagerXMLAdapter"
+ provides="Products.GenericSetup.interfaces.IBody"
+ for="Products.CMFCore.interfaces.ICachingPolicyManager
+ Products.GenericSetup.interfaces.ISetupContext"
/>
<adapter
- factory=".cachingpolicymgr.CachingPolicyManagerNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeImporter"
- for="Products.CMFCore.interfaces.ICachingPolicyManager"
- />
-
- <adapter
factory=".content.StructureFolderWalkingAdapter"
provides="Products.GenericSetup.interfaces.IFilesystemExporter"
for="Products.CMFCore.interfaces.IFolderish"
@@ -70,42 +65,27 @@
/>
<adapter
- factory=".contenttyperegistry.ContentTypeRegistryNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeExporter"
- for="Products.CMFCore.interfaces.IContentTypeRegistry"
+ factory=".contenttyperegistry.ContentTypeRegistryXMLAdapter"
+ provides="Products.GenericSetup.interfaces.IBody"
+ for="Products.CMFCore.interfaces.IContentTypeRegistry
+ Products.GenericSetup.interfaces.ISetupContext"
/>
<adapter
- factory=".contenttyperegistry.ContentTypeRegistryNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeImporter"
- for="Products.CMFCore.interfaces.IContentTypeRegistry"
+ factory=".cookieauth.CookieCrumblerXMLAdapter"
+ provides="Products.GenericSetup.interfaces.IBody"
+ for="Products.CMFCore.interfaces.ICookieCrumbler
+ Products.GenericSetup.interfaces.ISetupContext"
/>
<adapter
- factory=".cookieauth.CookieCrumblerNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeExporter"
- for="Products.CMFCore.interfaces.ICookieCrumbler"
+ factory=".properties.PropertiesXMLAdapter"
+ provides="Products.GenericSetup.interfaces.IBody"
+ for="Products.CMFCore.interfaces.ISiteRoot
+ Products.GenericSetup.interfaces.ISetupContext"
/>
<adapter
- factory=".cookieauth.CookieCrumblerNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeImporter"
- for="Products.CMFCore.interfaces.ICookieCrumbler"
- />
-
- <adapter
- factory=".properties.PropertiesNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeExporter"
- for="Products.CMFCore.interfaces.ISiteRoot"
- />
-
- <adapter
- factory=".properties.PropertiesNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeImporter"
- for="Products.CMFCore.interfaces.ISiteRoot"
- />
-
- <adapter
factory=".skins.DirectoryViewNodeAdapter"
provides="Products.GenericSetup.interfaces.INodeExporter"
for="Products.CMFCore.interfaces.IDirectoryView"
Modified: CMF/trunk/CMFCore/exportimport/contenttyperegistry.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/contenttyperegistry.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/contenttyperegistry.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -10,30 +10,40 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Content type registry node adapters.
+"""Content type registry xml adapters and setup handlers.
$Id$
"""
+from zope.app import zapi
+
+from Products.GenericSetup.interfaces import IBody
from Products.GenericSetup.interfaces import PURGE
-from Products.GenericSetup.utils import NodeAdapterBase
+from Products.GenericSetup.utils import XMLAdapterBase
from Products.CMFCore.interfaces import IContentTypeRegistry
+from Products.CMFCore.utils import getToolByName
+_FILENAME = 'contenttyperegistry.xml'
-class ContentTypeRegistryNodeAdapter(NodeAdapterBase):
- """Node im- and exporter for ContentTypeRegistry.
+class ContentTypeRegistryXMLAdapter(XMLAdapterBase):
+
+ """XML im- and exporter for ContentTypeRegistry.
"""
__used_for__ = IContentTypeRegistry
+ _LOGGER_ID = 'contenttypes'
+
def exportNode(self, doc):
"""Export the object as a DOM node.
"""
self._doc = doc
node = self._getObjectNode('object')
node.appendChild(self._extractPredicates())
+
+ self._logger.info('Content type registry exported.')
return node
def importNode(self, node, mode=PURGE):
@@ -44,6 +54,8 @@
self._initPredicates(node, mode)
+ self._logger.info('Content type registry imported.')
+
def _extractPredicates(self):
fragment = self._doc.createDocumentFragment()
for predicate_id, info in self.context.listPredicates():
@@ -97,3 +109,40 @@
if cracker is not None:
return cracker(predicate)
return () # XXX: raise?
+
+
+def importContentTypeRegistry(context):
+ """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
+
+ 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.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)
Modified: CMF/trunk/CMFCore/exportimport/cookieauth.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/cookieauth.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/cookieauth.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -10,31 +10,41 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Cookie crumbler node adapters.
+"""Cookie crumbler xml adapters and setup handlers.
$Id$
"""
+from zope.app import zapi
+
+from Products.GenericSetup.interfaces import IBody
from Products.GenericSetup.interfaces import PURGE
-from Products.GenericSetup.utils import NodeAdapterBase
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 CookieCrumblerNodeAdapter(NodeAdapterBase, PropertyManagerHelpers):
- """Node im- and exporter for CookieCrumbler.
+class CookieCrumblerXMLAdapter(XMLAdapterBase, PropertyManagerHelpers):
+
+ """XML im- and exporter for CookieCrumbler.
"""
__used_for__ = ICookieCrumbler
+ _LOGGER_ID = 'cookies'
+
def exportNode(self, doc):
"""Export the object as a DOM node.
"""
self._doc = doc
node = self._getObjectNode('object')
node.appendChild(self._extractProperties())
+
+ self._logger.info('Cookie crumbler exported.')
return node
def importNode(self, node, mode=PURGE):
@@ -44,3 +54,42 @@
self._purgeProperties()
self._initProperties(node, mode)
+
+ self._logger.info('Cookie crumbler imported.')
+
+
+def importCookieCrumbler(context):
+ """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
+
+ 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.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)
Copied: CMF/trunk/CMFCore/exportimport/mailhost.py (from rev 40391, CMF/trunk/CMFSetup/mailhost.py)
===================================================================
--- CMF/trunk/CMFSetup/mailhost.py 2005-11-28 16:21:21 UTC (rev 40391)
+++ CMF/trunk/CMFCore/exportimport/mailhost.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -0,0 +1,61 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Mailhost setup handlers.
+
+$Id$
+"""
+
+from zope.app import zapi
+
+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
+
+ 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.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)
Modified: CMF/trunk/CMFCore/exportimport/properties.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/properties.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/properties.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -10,31 +10,40 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Site properties node adapters.
+"""Site properties xml adapters and setup handlers.
$Id$
"""
+from zope.app import zapi
+
+from Products.GenericSetup.interfaces import IBody
from Products.GenericSetup.interfaces import PURGE
-from Products.GenericSetup.utils import NodeAdapterBase
from Products.GenericSetup.utils import PropertyManagerHelpers
+from Products.GenericSetup.utils import XMLAdapterBase
from Products.CMFCore.interfaces import ISiteRoot
+_FILENAME = 'properties.xml'
-class PropertiesNodeAdapter(NodeAdapterBase, PropertyManagerHelpers):
- """Node im- and exporter for properties.
+class PropertiesXMLAdapter(XMLAdapterBase, PropertyManagerHelpers):
+
+ """XML im- and exporter for properties.
"""
__used_for__ = ISiteRoot
+ _LOGGER_ID = 'properties'
+
def exportNode(self, doc):
"""Export the object as a DOM node.
"""
self._doc = doc
node = self._doc.createElement('site')
node.appendChild(self._extractProperties())
+
+ self._logger.info('Site properties exported.')
return node
def importNode(self, node, mode=PURGE):
@@ -44,3 +53,37 @@
self._purgeProperties()
self._initProperties(node, mode)
+
+ self._logger.info('Site properties imported.')
+
+
+def importSiteProperties(context):
+ """ Import site properties from an XML file.
+ """
+ site = context.getSite()
+ logger = context.getLogger('properties')
+
+ body = context.readDataFile(_FILENAME)
+ if body is None:
+ logger.info('Nothing to import.')
+ return
+
+ importer = zapi.queryMultiAdapter((site, context), IBody)
+ if importer is None:
+ logger.warning('Import adapter misssing.')
+ return
+
+ importer.body = body
+
+def exportSiteProperties(context):
+ """ Export site properties as an XML file.
+ """
+ site = context.getSite()
+ logger = context.getLogger('properties')
+
+ exporter = zapi.queryMultiAdapter((site, context), IBody)
+ if exporter is None:
+ logger.warning('Export adapter misssing.')
+ return
+
+ context.writeDataFile(_FILENAME, exporter.body, exporter.mime_type)
Modified: CMF/trunk/CMFCore/exportimport/skins.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/skins.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/skins.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -234,7 +234,7 @@
logger.info('Nothing to export.')
return
- exporter = zapi.getMultiAdapter((tool, context), IBody)
+ exporter = zapi.queryMultiAdapter((tool, context), IBody)
if exporter is None:
logger.warning('Export adapter misssing.')
return
Modified: CMF/trunk/CMFCore/exportimport/tests/test_actions.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_actions.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/tests/test_actions.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -40,7 +40,6 @@
from Products.GenericSetup.tests.common import DummyExportContext
from Products.GenericSetup.tests.common import DummyImportContext
-
_ACTION_XML = """\
<object name="foo_action" meta_type="CMF Action">
<property name="title">Foo</property>
@@ -425,12 +424,10 @@
import exportActionProviders
site = self._initSite()
-
context = DummyExportContext(site)
exportActionProviders(context)
self.assertEqual(len(context._wrote), 1)
-
filename, text, content_type = context._wrote[0]
self.assertEqual(filename, 'actions.xml')
self._compareDOM(text, _NORMAL_EXPORT)
Modified: CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Caching policy manager node adapter unit tests.
+"""Caching policy manager xml adapter and setup handler unit tests.
$Id$
"""
@@ -18,9 +18,17 @@
import unittest
import Testing
-from Products.CMFCore.tests.base.testcase import PlacelessSetup
+import Products
+from OFS.Folder import Folder
+from Products.Five import zcml
+
+from Products.GenericSetup.testing import BodyAdapterTestCase
from Products.GenericSetup.testing import NodeAdapterTestCase
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
_CP_XML = """\
<caching-policy name="foo_policy" enable_304s="False" etag_func=""
@@ -30,7 +38,8 @@
proxy_revalidate="False" public="False" vary=""/>
"""
-_CPM_XML = """\
+_CPM_BODY = """\
+<?xml version="1.0"?>
<object name="caching_policy_manager" meta_type="CMF Caching Policy Manager">
<caching-policy name="foo_policy" enable_304s="False" etag_func=""
last_modified="True" max_age_secs="600" mtime_func="object/modified"
@@ -64,14 +73,13 @@
self._XML = _CP_XML
-class CachingPolicyManagerNodeAdapterTests(PlacelessSetup,
- NodeAdapterTestCase):
+class CachingPolicyManagerXMLAdapterTests(BodyAdapterTestCase):
def _getTargetClass(self):
from Products.CMFCore.exportimport.cachingpolicymgr \
- import CachingPolicyManagerNodeAdapter
+ import CachingPolicyManagerXMLAdapter
- return CachingPolicyManagerNodeAdapter
+ return CachingPolicyManagerXMLAdapter
def _populate(self, obj):
obj.addPolicy('foo_policy',
@@ -79,23 +87,161 @@
'object/modified', 600, 0, 0, 0, '', '')
def setUp(self):
+ import Products.CMFCore.exportimport
from Products.CMFCore.CachingPolicyManager import CachingPolicyManager
- import Products.CMFCore.exportimport
- import Products.Five
- from Products.Five import zcml
+ BodyAdapterTestCase.setUp(self)
+ zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
+
+ self._obj = CachingPolicyManager()
+ self._BODY = _CPM_BODY
+
+
+class _CachingPolicyManagerSetup(PlacelessSetup, BaseRegistryTests):
+
+ POLICY_ID = 'policy_id'
+ PREDICATE = "python:object.getId() == 'foo'"
+ MTIME_FUNC = "object/modified"
+ MAX_AGE_SECS = 60
+ VARY = "Test"
+ ETAG_FUNC = "object/getETag"
+ S_MAX_AGE_SECS = 120
+ PRE_CHECK = 42
+ POST_CHECK = 43
+
+ _EMPTY_EXPORT = """\
+<?xml version="1.0"?>
+<object name="caching_policy_manager" meta_type="CMF Caching Policy Manager"/>
+"""
+
+ _WITH_POLICY_EXPORT = """\
+<?xml version="1.0"?>
+<object name="caching_policy_manager" meta_type="CMF Caching Policy Manager">
+ <caching-policy name="%s" enable_304s="True"
+ etag_func="%s" last_modified="False" max_age_secs="%d"
+ mtime_func="%s" must_revalidate="True" no_cache="True"
+ no_store="True" no_transform="True" post_check="%d" pre_check="%d"
+ predicate="%s" private="True"
+ proxy_revalidate="True" public="True" s_max_age_secs="%d" vary="%s"/>
+</object>
+""" % (POLICY_ID, ETAG_FUNC, MAX_AGE_SECS, MTIME_FUNC, POST_CHECK, PRE_CHECK,
+ PREDICATE, S_MAX_AGE_SECS, VARY)
+
+ def _initSite(self, with_policy=False):
+ from Products.CMFCore.CachingPolicyManager import CachingPolicyManager
+
+ self.root.site = Folder(id='site')
+ site = self.root.site
+ mgr = CachingPolicyManager()
+ site._setObject( mgr.getId(), mgr )
+
+ if with_policy:
+ mgr.addPolicy( policy_id=self.POLICY_ID
+ , predicate=self.PREDICATE
+ , mtime_func=self.MTIME_FUNC
+ , max_age_secs=self.MAX_AGE_SECS
+ , no_cache=True
+ , no_store=True
+ , must_revalidate=True
+ , vary=self.VARY
+ , etag_func=self.ETAG_FUNC
+ , s_max_age_secs=self.S_MAX_AGE_SECS
+ , proxy_revalidate=True
+ , public=True
+ , private=True
+ , no_transform=True
+ , enable_304s=True
+ , last_modified=False
+ , pre_check=self.PRE_CHECK
+ , post_check=self.POST_CHECK
+ )
+
+ return site
+
+ def setUp(self):
PlacelessSetup.setUp(self)
+ BaseRegistryTests.setUp(self)
zcml.load_config('meta.zcml', Products.Five)
zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
- self._obj = CachingPolicyManager()
- self._XML = _CPM_XML
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
+class exportCachingPolicyManagerTests(_CachingPolicyManagerSetup):
+
+ def test_empty(self):
+ from Products.CMFCore.exportimport.cachingpolicymgr \
+ import exportCachingPolicyManager
+
+ site = self._initSite(with_policy=False)
+ context = DummyExportContext(site)
+ exportCachingPolicyManager(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'cachingpolicymgr.xml')
+ self._compareDOM(text, self._EMPTY_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+ def test_with_policy(self):
+ from Products.CMFCore.exportimport.cachingpolicymgr \
+ import exportCachingPolicyManager
+
+ site = self._initSite(with_policy=True)
+ context = DummyExportContext(site)
+ exportCachingPolicyManager(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'cachingpolicymgr.xml')
+ self._compareDOM(text, self._WITH_POLICY_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+
+class importCachingPolicyManagerTests(_CachingPolicyManagerSetup):
+
+ def test_normal(self):
+ from Products.CMFCore.exportimport.cachingpolicymgr \
+ import importCachingPolicyManager
+
+ site = self._initSite(with_policy=False)
+ cpm = site.caching_policy_manager
+ self.assertEqual(len(cpm.listPolicies()), 0)
+
+ context = DummyImportContext(site)
+ context._files['cachingpolicymgr.xml'] = self._WITH_POLICY_EXPORT
+ importCachingPolicyManager(context)
+
+ self.assertEqual(len(cpm.listPolicies()), 1)
+ policy_id, policy = cpm.listPolicies()[0]
+ self.assertEqual(policy.getPolicyId(), self.POLICY_ID)
+ self.assertEqual(policy.getPredicate(), self.PREDICATE)
+ self.assertEqual(policy.getMTimeFunc(), self.MTIME_FUNC)
+ self.assertEqual(policy.getVary(), self.VARY)
+ self.assertEqual(policy.getETagFunc(), self.ETAG_FUNC)
+ self.assertEqual(policy.getMaxAgeSecs(), self.MAX_AGE_SECS)
+ self.assertEqual(policy.getSMaxAgeSecs(), self.S_MAX_AGE_SECS)
+ self.assertEqual(policy.getPreCheck(), self.PRE_CHECK)
+ self.assertEqual(policy.getPostCheck(), self.POST_CHECK)
+ self.assertEqual(policy.getLastModified(), False)
+ self.assertEqual(policy.getNoCache(), True)
+ self.assertEqual(policy.getNoStore(), True)
+ self.assertEqual(policy.getMustRevalidate(), True)
+ self.assertEqual(policy.getProxyRevalidate(), True)
+ self.assertEqual(policy.getNoTransform(), True)
+ self.assertEqual(policy.getPublic(), True)
+ self.assertEqual(policy.getPrivate(), True)
+ self.assertEqual(policy.getEnable304s(), True)
+
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(CachingPolicyNodeAdapterTests),
- unittest.makeSuite(CachingPolicyManagerNodeAdapterTests),
+ unittest.makeSuite(CachingPolicyManagerXMLAdapterTests),
+ unittest.makeSuite(exportCachingPolicyManagerTests),
+ unittest.makeSuite(importCachingPolicyManagerTests),
))
if __name__ == '__main__':
Copied: CMF/trunk/CMFCore/exportimport/tests/test_catalog.py (from rev 40391, CMF/trunk/CMFSetup/tests/test_catalog.py)
===================================================================
--- CMF/trunk/CMFSetup/tests/test_catalog.py 2005-11-28 16:21:21 UTC (rev 40391)
+++ CMF/trunk/CMFCore/exportimport/tests/test_catalog.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -0,0 +1,242 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Catalog tool setup handler unit tests.
+
+$Id$
+"""
+
+import unittest
+import Testing
+import Zope2
+Zope2.startup()
+
+import Products
+from OFS.Folder import Folder
+from Products.Five import zcml
+from Products.ZCTextIndex.Lexicon import CaseNormalizer
+from Products.ZCTextIndex.Lexicon import Splitter
+from Products.ZCTextIndex.Lexicon import StopWordRemover
+from Products.ZCTextIndex.ZCTextIndex import PLexicon
+
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
+
+from Products.CMFCore.CatalogTool import CatalogTool
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
+
+_EMPTY_EXPORT = """\
+<?xml version="1.0"?>
+<object meta_type="CMF Catalog" name="portal_catalog">
+ <property name="title"/>
+</object>
+"""
+
+_NORMAL_EXPORT = """\
+<?xml version="1.0"?>
+<object meta_type="CMF Catalog" name="portal_catalog">
+ <property name="title"/>
+ <object name="foo_plexicon" meta_type="ZCTextIndex Lexicon">
+ <element name="Whitespace splitter" group="Word Splitter"/>
+ <element name="Case Normalizer" group="Case Normalizer"/>
+ <element name="Remove listed stop words only" group="Stop Words"/>
+ </object>
+ <index name="foo_zctext" meta_type="ZCTextIndex">
+ <indexed_attr value="foo_zctext"/>
+ <extra name="index_type" value="Okapi BM25 Rank"/>
+ <extra name="lexicon_id" value="foo_plexicon"/>
+ </index>
+ <column value="foo_zctext"/>
+</object>
+"""
+
+_UPDATE_IMPORT = """\
+<?xml version="1.0"?>
+<object meta_type="CMF Catalog" name="portal_catalog">
+ <index name="foo_date" meta_type="DateIndex">
+ <property name="index_naive_time_as_local">True</property>
+ </index>
+ <column value="foo_date"/>
+</object>
+"""
+
+
+class _extra:
+
+ pass
+
+
+class _CatalogToolSetup(PlacelessSetup, BaseRegistryTests):
+
+ def _initSite(self, foo=2):
+ site = self.root.site = Folder(id='site')
+ ctool = site.portal_catalog = CatalogTool()
+
+ for obj_id in ctool.objectIds():
+ ctool._delObject(obj_id)
+ for idx_id in ctool.indexes():
+ ctool.delIndex(idx_id)
+ for col in ctool.schema()[:]:
+ ctool.delColumn(col)
+
+ if foo > 0:
+ ctool._setObject('foo_plexicon', PLexicon('foo_plexicon'))
+ lex = ctool.foo_plexicon
+ lex._pipeline = (Splitter(), CaseNormalizer(), StopWordRemover())
+
+ extra = _extra()
+ extra.lexicon_id = 'foo_plexicon'
+ extra.index_type = 'Okapi BM25 Rank'
+ ctool.addIndex('foo_zctext', 'ZCTextIndex', extra)
+
+ ctool.addColumn('foo_zctext')
+
+ return site
+
+ def setUp(self):
+ PlacelessSetup.setUp(self)
+ BaseRegistryTests.setUp(self)
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('configure.zcml',
+ Products.GenericSetup.PluginIndexes)
+ zcml.load_config('configure.zcml', Products.GenericSetup.ZCatalog)
+ zcml.load_config('configure.zcml', Products.GenericSetup.ZCTextIndex)
+
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
+
+
+class exportCatalogToolTests(_CatalogToolSetup):
+
+ def test_unchanged(self):
+ from Products.CMFCore.exportimport.catalog import exportCatalogTool
+
+ site = self._initSite(0)
+ context = DummyExportContext(site)
+ exportCatalogTool(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'catalog.xml')
+ self._compareDOM(text, _EMPTY_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+ def test_normal(self):
+ from Products.CMFCore.exportimport.catalog import exportCatalogTool
+
+ site = self._initSite(2)
+ context = DummyExportContext(site)
+ exportCatalogTool(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'catalog.xml')
+ self._compareDOM(text, _NORMAL_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+
+class importCatalogToolTests(_CatalogToolSetup):
+
+ def test_empty_purge(self):
+ from Products.CMFCore.exportimport.catalog import importCatalogTool
+
+ site = self._initSite(2)
+ ctool = site.portal_catalog
+
+ self.assertEqual(len(ctool.objectIds()), 1)
+ self.assertEqual(len(ctool.indexes()), 1)
+ self.assertEqual(len(ctool.schema()), 1)
+
+ context = DummyImportContext(site, True)
+ context._files['catalog.xml'] = _EMPTY_EXPORT
+ importCatalogTool(context)
+
+ self.assertEqual(len(ctool.objectIds()), 0)
+ self.assertEqual(len(ctool.indexes()), 0)
+ self.assertEqual(len(ctool.schema()), 0)
+
+ def test_empty_update(self):
+ from Products.CMFCore.exportimport.catalog import importCatalogTool
+
+ site = self._initSite(2)
+ ctool = site.portal_catalog
+
+ self.assertEqual(len(ctool.objectIds()), 1)
+ self.assertEqual(len(ctool.indexes()), 1)
+ self.assertEqual(len(ctool.schema()), 1)
+
+ context = DummyImportContext(site, False)
+ context._files['catalog.xml'] = _EMPTY_EXPORT
+ importCatalogTool(context)
+
+ self.assertEqual(len(ctool.objectIds()), 1)
+ self.assertEqual(len(ctool.indexes()), 1)
+ self.assertEqual(len(ctool.schema()), 1)
+
+ def test_normal_purge(self):
+ from Products.CMFCore.exportimport.catalog import exportCatalogTool
+ from Products.CMFCore.exportimport.catalog import importCatalogTool
+
+ site = self._initSite(2)
+ ctool = site.portal_catalog
+
+ self.assertEqual(len(ctool.objectIds()), 1)
+ self.assertEqual(len(ctool.indexes()), 1)
+ self.assertEqual(len(ctool.schema()), 1)
+
+ context = DummyImportContext(site, True)
+ context._files['catalog.xml'] = _NORMAL_EXPORT
+ importCatalogTool(context)
+
+ self.assertEqual(len(ctool.objectIds()), 1)
+ self.assertEqual(len(ctool.indexes()), 1)
+ self.assertEqual(len(ctool.schema()), 1)
+
+ # complete the roundtrip
+ context = DummyExportContext(site)
+ exportCatalogTool(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'catalog.xml')
+ self._compareDOM(text, _NORMAL_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+ def test_normal_update(self):
+ from Products.CMFCore.exportimport.catalog import importCatalogTool
+
+ site = self._initSite(2)
+ ctool = site.portal_catalog
+
+ self.assertEqual(len(ctool.objectIds()), 1)
+ self.assertEqual(len(ctool.indexes()), 1)
+ self.assertEqual(len(ctool.schema()), 1)
+
+ context = DummyImportContext(site, False)
+ context._files['catalog.xml'] = _UPDATE_IMPORT
+ importCatalogTool(context)
+
+ self.assertEqual(len(ctool.objectIds()), 1)
+ self.assertEqual(len(ctool.indexes()), 2)
+ self.assertEqual(len(ctool.schema()), 2)
+
+
+def test_suite():
+ return unittest.TestSuite((
+ unittest.makeSuite(exportCatalogToolTests),
+ unittest.makeSuite(importCatalogToolTests),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Modified: CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Content type registry node adapter unit tests.
+"""Content type registry xml adapter and setup handler unit tests.
$Id$
"""
@@ -18,11 +18,26 @@
import unittest
import Testing
+import Products
+from OFS.Folder import Folder
+from Products.Five import zcml
+
+from Products.GenericSetup.testing import BodyAdapterTestCase
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
+
from Products.CMFCore.tests.base.testcase import PlacelessSetup
-from Products.GenericSetup.testing import NodeAdapterTestCase
+_TEST_PREDICATES = (
+ ('plain_text', 'major_minor', ('text', 'plain,javascript'), 'File'),
+ ('stylesheets', 'extension', ('css,xsl,xslt',), 'Text File'),
+ ('images', 'mimetype_regex', ('image/.*',), 'Image'),
+ ('logfiles', 'name_regex', ('error_log-.*',), 'Log File'),
+)
-_CTR_XML = """\
+_CTR_BODY = """\
+<?xml version="1.0"?>
<object name="content_type_registry" meta_type="Content Type Registry">
<predicate name="foo_predicate" content_type_name="Foo Type"
predicate_type="major_minor">
@@ -45,14 +60,13 @@
"""
-class ContentTypeRegistryNodeAdapterTests(PlacelessSetup,
- NodeAdapterTestCase):
+class ContentTypeRegistryXMLAdapterTests(BodyAdapterTestCase):
def _getTargetClass(self):
from Products.CMFCore.exportimport.contenttyperegistry \
- import ContentTypeRegistryNodeAdapter
+ import ContentTypeRegistryXMLAdapter
- return ContentTypeRegistryNodeAdapter
+ return ContentTypeRegistryXMLAdapter
def _populate(self, obj):
obj.addPredicate('foo_predicate', 'major_minor')
@@ -69,22 +83,176 @@
obj.assignTypeName('foobar_predicate', 'Foobar Type')
def setUp(self):
+ import Products.CMFCore.exportimport
from Products.CMFCore.ContentTypeRegistry import ContentTypeRegistry
- import Products.CMFCore.exportimport
- import Products.Five
- from Products.Five import zcml
+ BodyAdapterTestCase.setUp(self)
+ zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
+
+ self._obj = ContentTypeRegistry()
+ self._BODY = _CTR_BODY
+
+
+class _ContentTypeRegistrySetup(PlacelessSetup, BaseRegistryTests):
+
+ MAJOR_MINOR_ID = _TEST_PREDICATES[0][0]
+ MAJOR = _TEST_PREDICATES[0][2][0]
+ MINOR = _TEST_PREDICATES[0][2][1]
+ MAJOR_MINOR_TYPENAME = _TEST_PREDICATES[0][3]
+ EXTENSION_ID = _TEST_PREDICATES[1][0]
+ EXTENSIONS = _TEST_PREDICATES[1][2][0]
+ EXTENSION_TYPENAME = _TEST_PREDICATES[1][3]
+ MIMETYPE_REGEX_ID = _TEST_PREDICATES[2][0]
+ MIMETYPE_REGEX = _TEST_PREDICATES[2][2][0]
+ MIMETYPE_REGEX_TYPENAME = _TEST_PREDICATES[2][3]
+ NAME_REGEX_ID = _TEST_PREDICATES[3][0]
+ NAME_REGEX = _TEST_PREDICATES[3][2][0]
+ NAME_REGEX_TYPENAME = _TEST_PREDICATES[3][3]
+
+ _EMPTY_EXPORT = """\
+<?xml version="1.0"?>
+<object name="content_type_registry" meta_type="Content Type Registry"/>
+"""
+
+ _WITH_POLICY_EXPORT = """\
+<?xml version="1.0"?>
+<object name="content_type_registry" meta_type="Content Type Registry">
+ <predicate name="%s" content_type_name="%s"
+ predicate_type="major_minor">
+ <argument value="%s"/>
+ <argument value="%s"/>
+ </predicate>
+ <predicate name="%s" content_type_name="%s"
+ predicate_type="extension">
+ <argument value="%s"/>
+ </predicate>
+ <predicate name="%s" content_type_name="%s"
+ predicate_type="mimetype_regex">
+ <argument value="%s"/>
+ </predicate>
+ <predicate name="%s" content_type_name="%s"
+ predicate_type="name_regex">
+ <argument value="%s"/>
+ </predicate>
+</object>
+""" % (MAJOR_MINOR_ID,
+ MAJOR_MINOR_TYPENAME,
+ MAJOR,
+ MINOR,
+ EXTENSION_ID,
+ EXTENSION_TYPENAME,
+ EXTENSIONS,
+ MIMETYPE_REGEX_ID,
+ MIMETYPE_REGEX_TYPENAME,
+ MIMETYPE_REGEX,
+ NAME_REGEX_ID,
+ NAME_REGEX_TYPENAME,
+ NAME_REGEX,
+ )
+
+ def _initSite(self, mit_predikat=False):
+ from Products.CMFCore.ContentTypeRegistry import ContentTypeRegistry
+
+ self.root.site = Folder(id='site')
+ site = self.root.site
+ ctr = ContentTypeRegistry()
+ site._setObject( ctr.getId(), ctr )
+
+ if mit_predikat:
+ for (predicate_id, predicate_type, edit_args, content_type_name
+ ) in _TEST_PREDICATES:
+ ctr.addPredicate(predicate_id, predicate_type)
+ predicate = ctr.getPredicate(predicate_id)
+ predicate.edit(*edit_args)
+ ctr.assignTypeName(predicate_id, content_type_name)
+
+ return site
+
+ def setUp(self):
PlacelessSetup.setUp(self)
+ BaseRegistryTests.setUp(self)
zcml.load_config('meta.zcml', Products.Five)
zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
- self._obj = ContentTypeRegistry()
- self._XML = _CTR_XML
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
+class exportContentTypeRegistryTests(_ContentTypeRegistrySetup):
+
+ def test_empty(self):
+ from Products.CMFCore.exportimport.contenttyperegistry \
+ import exportContentTypeRegistry
+
+ site = self._initSite(mit_predikat=False)
+ context = DummyExportContext(site)
+ exportContentTypeRegistry(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'contenttyperegistry.xml')
+ self._compareDOM(text, self._EMPTY_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+ def test_with_policy(self):
+ from Products.CMFCore.exportimport.contenttyperegistry \
+ import exportContentTypeRegistry
+
+ site = self._initSite(mit_predikat=True)
+ context = DummyExportContext(site)
+ exportContentTypeRegistry(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'contenttyperegistry.xml')
+ self._compareDOM(text, self._WITH_POLICY_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+
+class importContentTypeRegistryTests(_ContentTypeRegistrySetup):
+
+ def test_normal(self):
+ from Products.CMFCore.exportimport.contenttyperegistry \
+ import importContentTypeRegistry
+
+ site = self._initSite(mit_predikat=False)
+ ctr = site.content_type_registry
+ self.assertEqual(len(ctr.listPredicates()), 0)
+
+ context = DummyImportContext(site)
+ context._files['contenttyperegistry.xml'] = self._WITH_POLICY_EXPORT
+ importContentTypeRegistry(context)
+
+ self.assertEqual(len(ctr.listPredicates()), len(_TEST_PREDICATES))
+ predicate_id, (predicate, content_type_name) = ctr.listPredicates()[0]
+ self.assertEqual(predicate_id, self.MAJOR_MINOR_ID)
+ self.assertEqual(predicate.PREDICATE_TYPE, 'major_minor')
+ self.assertEqual(content_type_name, self.MAJOR_MINOR_TYPENAME)
+ self.assertEqual(predicate.major, self.MAJOR.split(','))
+ self.assertEqual(predicate.minor, self.MINOR.split(','))
+ predicate_id, (predicate, content_type_name) = ctr.listPredicates()[1]
+ self.assertEqual(predicate_id, self.EXTENSION_ID)
+ self.assertEqual(predicate.PREDICATE_TYPE, 'extension')
+ self.assertEqual(content_type_name, self.EXTENSION_TYPENAME)
+ self.assertEqual(predicate.extensions, self.EXTENSIONS.split(','))
+ predicate_id, (predicate, content_type_name) = ctr.listPredicates()[2]
+ self.assertEqual(predicate_id, self.MIMETYPE_REGEX_ID)
+ self.assertEqual(predicate.PREDICATE_TYPE, 'mimetype_regex')
+ self.assertEqual(content_type_name, self.MIMETYPE_REGEX_TYPENAME)
+ self.assertEqual(predicate.pattern.pattern, self.MIMETYPE_REGEX)
+ predicate_id, (predicate, content_type_name) = ctr.listPredicates()[3]
+ self.assertEqual(predicate_id, self.NAME_REGEX_ID)
+ self.assertEqual(predicate.PREDICATE_TYPE, 'name_regex')
+ self.assertEqual(content_type_name, self.NAME_REGEX_TYPENAME)
+ self.assertEqual(predicate.pattern.pattern, self.NAME_REGEX)
+
+
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(ContentTypeRegistryNodeAdapterTests),
+ unittest.makeSuite(ContentTypeRegistryXMLAdapterTests),
+ unittest.makeSuite(exportContentTypeRegistryTests),
+ unittest.makeSuite(importContentTypeRegistryTests),
))
if __name__ == '__main__':
Modified: CMF/trunk/CMFCore/exportimport/tests/test_cookieauth.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_cookieauth.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/tests/test_cookieauth.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Cookie crumbler node adapter unit tests.
+"""Cookie crumbler xml adapter and setup handler unit tests.
$Id$
"""
@@ -18,11 +18,36 @@
import unittest
import Testing
+import Products
+from OFS.Folder import Folder
+from Products.Five import zcml
+
+from Products.GenericSetup.testing import BodyAdapterTestCase
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
+
+from Products.CMFCore.CookieCrumbler import CookieCrumbler
from Products.CMFCore.tests.base.testcase import PlacelessSetup
-from Products.GenericSetup.testing import NodeAdapterTestCase
+_COOKIECRUMBLER_BODY = """\
+<?xml version="1.0"?>
+<object name="foo_cookiecrumbler" meta_type="Cookie Crumbler">
+ <property name="auth_cookie">__ac</property>
+ <property name="name_cookie">__ac_name</property>
+ <property name="pw_cookie">__ac_password</property>
+ <property name="persist_cookie">__ac_persistent</property>
+ <property name="auto_login_page">login_form</property>
+ <property name="logout_page">logged_out</property>
+ <property name="unauth_page"></property>
+ <property name="local_cookie_path">False</property>
+ <property name="cache_header_value">private</property>
+ <property name="log_username">True</property>
+</object>
+"""
-_COOKIECRUMBLER_XML = """\
+_DEFAULT_EXPORT = """\
+<?xml version="1.0"?>
<object name="foo_cookiecrumbler" meta_type="Cookie Crumbler">
<property name="auth_cookie">__ac</property>
<property name="name_cookie">__ac_name</property>
@@ -37,32 +62,135 @@
</object>
"""
+_CHANGED_EXPORT = """\
+<?xml version="1.0"?>
+<object name="foo_cookiecrumbler" meta_type="Cookie Crumbler">
+ <property name="auth_cookie">value1</property>
+ <property name="name_cookie">value3</property>
+ <property name="pw_cookie">value5</property>
+ <property name="persist_cookie">value4</property>
+ <property name="auto_login_page">value6</property>
+ <property name="logout_page">value8</property>
+ <property name="unauth_page">value7</property>
+ <property name="local_cookie_path">True</property>
+ <property name="cache_header_value">value2</property>
+ <property name="log_username">False</property>
+</object>
+"""
-class CookieCrumblerNodeAdapterTests(PlacelessSetup, NodeAdapterTestCase):
+class CookieCrumblerXMLAdapterTests(BodyAdapterTestCase):
+
def _getTargetClass(self):
from Products.CMFCore.exportimport.cookieauth \
- import CookieCrumblerNodeAdapter
+ import CookieCrumblerXMLAdapter
- return CookieCrumblerNodeAdapter
+ return CookieCrumblerXMLAdapter
def setUp(self):
+ import Products.CMFCore.exportimport
from Products.CMFCore.CookieCrumbler import CookieCrumbler
- import Products.CMFCore.exportimport
- import Products.Five
- from Products.Five import zcml
+ BodyAdapterTestCase.setUp(self)
+ zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
+
+ self._obj = CookieCrumbler('foo_cookiecrumbler')
+ self._BODY = _COOKIECRUMBLER_BODY
+
+
+class _CookieCrumblerSetup(PlacelessSetup, BaseRegistryTests):
+
+ def _initSite(self, use_changed=False):
+ self.root.site = Folder(id='site')
+ site = self.root.site
+ cc = site.cookie_authentication = CookieCrumbler('foo_cookiecrumbler')
+
+ if use_changed:
+ cc.auth_cookie = 'value1'
+ cc.cache_header_value = 'value2'
+ cc.name_cookie = 'value3'
+ cc.log_username = 0
+ cc.persist_cookie = 'value4'
+ cc.pw_cookie = 'value5'
+ cc.local_cookie_path = 1
+ cc.auto_login_page = 'value6'
+ cc.unauth_page = 'value7'
+ cc.logout_page = 'value8'
+
+ return site
+
+ def setUp(self):
PlacelessSetup.setUp(self)
+ BaseRegistryTests.setUp(self)
zcml.load_config('meta.zcml', Products.Five)
zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
- self._obj = CookieCrumbler('foo_cookiecrumbler')
- self._XML = _COOKIECRUMBLER_XML
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
+class exportCookieCrumblerTests(_CookieCrumblerSetup):
+
+ def test_unchanged(self):
+ from Products.CMFCore.exportimport.cookieauth \
+ import exportCookieCrumbler
+
+ site = self._initSite(use_changed=False)
+ context = DummyExportContext(site)
+ exportCookieCrumbler(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'cookieauth.xml')
+ self._compareDOM(text, _DEFAULT_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+ def test_changed(self):
+ from Products.CMFCore.exportimport.cookieauth \
+ import exportCookieCrumbler
+
+ site = self._initSite(use_changed=True)
+ context = DummyExportContext(site)
+ exportCookieCrumbler(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'cookieauth.xml')
+ self._compareDOM(text, _CHANGED_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+
+class importCookieCrumblerTests(_CookieCrumblerSetup):
+
+ def test_normal(self):
+ from Products.CMFCore.exportimport.cookieauth \
+ import importCookieCrumbler
+
+ site = self._initSite()
+ cc = site.cookie_authentication
+
+ context = DummyImportContext(site)
+ context._files['cookieauth.xml'] = _CHANGED_EXPORT
+ importCookieCrumbler(context)
+
+ self.assertEqual( cc.auth_cookie, 'value1' )
+ self.assertEqual( cc.cache_header_value, 'value2' )
+ self.assertEqual( cc.name_cookie, 'value3' )
+ self.assertEqual( cc.log_username, 0 )
+ self.assertEqual( cc.persist_cookie, 'value4' )
+ self.assertEqual( cc.pw_cookie, 'value5' )
+ self.assertEqual( cc.local_cookie_path, 1 )
+ self.assertEqual( cc.auto_login_page, 'value6' )
+ self.assertEqual( cc.unauth_page, 'value7' )
+ self.assertEqual( cc.logout_page, 'value8' )
+
+
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(CookieCrumblerNodeAdapterTests),
+ unittest.makeSuite(CookieCrumblerXMLAdapterTests),
+ unittest.makeSuite(exportCookieCrumblerTests),
+ unittest.makeSuite(importCookieCrumblerTests),
))
if __name__ == '__main__':
Copied: CMF/trunk/CMFCore/exportimport/tests/test_mailhost.py (from rev 40391, CMF/trunk/CMFSetup/tests/test_mailhost.py)
===================================================================
--- CMF/trunk/CMFSetup/tests/test_mailhost.py 2005-11-28 16:21:21 UTC (rev 40391)
+++ CMF/trunk/CMFCore/exportimport/tests/test_mailhost.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -0,0 +1,127 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Mailhost setup handler unit tests.
+
+$Id$
+"""
+
+import unittest
+import Testing
+
+from OFS.Folder import Folder
+from Products.Five import zcml
+
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
+
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
+
+_DEFAULT_EXPORT = """\
+<?xml version="1.0"?>
+<object name="MailHost" meta_type="Mail Host" smtp_host="localhost"
+ smtp_port="25" smtp_pwd="" smtp_uid=""/>
+"""
+
+_CHANGED_EXPORT = """\
+<?xml version="1.0"?>
+<object name="MailHost" meta_type="Mail Host" smtp_host="value2"
+ smtp_port="1" smtp_pwd="value1" smtp_uid="value3"/>
+"""
+
+
+class _MailHostSetup(PlacelessSetup, BaseRegistryTests):
+
+ def _initSite(self, use_changed=False):
+ from Products.MailHost.MailHost import MailHost
+
+ self.root.site = Folder(id='site')
+ site = self.root.site
+ mh = site.MailHost = MailHost('MailHost')
+
+ if use_changed:
+ mh.smtp_port='1'
+ mh.smtp_pwd="value1"
+ mh.smtp_host="value2"
+ mh.smtp_uid="value3"
+
+ return site
+
+ def setUp(self):
+ import Products.GenericSetup.MailHost
+
+ PlacelessSetup.setUp(self)
+ BaseRegistryTests.setUp(self)
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('configure.zcml', Products.GenericSetup.MailHost)
+
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
+
+
+class exportMailHostTests(_MailHostSetup):
+
+ def test_unchanged(self):
+ from Products.CMFCore.exportimport.mailhost import exportMailHost
+
+ site = self._initSite(use_changed=False)
+ context = DummyExportContext(site)
+ exportMailHost(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'mailhost.xml')
+ self._compareDOM(text, _DEFAULT_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+ def test_changed(self):
+ from Products.CMFCore.exportimport.mailhost import exportMailHost
+
+ site = self._initSite(use_changed=True)
+ context = DummyExportContext(site)
+ exportMailHost(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'mailhost.xml')
+ self._compareDOM(text, _CHANGED_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+
+class importMailHostTests(_MailHostSetup):
+
+ def test_normal(self):
+ from Products.CMFCore.exportimport.mailhost import importMailHost
+
+ site = self._initSite()
+ mh = site.MailHost
+
+ context = DummyImportContext(site)
+ context._files['mailhost.xml'] = _CHANGED_EXPORT
+ importMailHost(context)
+
+ self.assertEqual( mh.smtp_pwd, 'value1' )
+ self.assertEqual( mh.smtp_host, 'value2' )
+ self.assertEqual( mh.smtp_uid, 'value3' )
+ self.assertEqual( mh.smtp_port, 1 )
+
+
+def test_suite():
+ return unittest.TestSuite((
+ unittest.makeSuite(exportMailHostTests),
+ unittest.makeSuite(importMailHostTests),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Modified: CMF/trunk/CMFCore/exportimport/tests/test_properties.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_properties.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/tests/test_properties.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Site properties node adapter unit tests.
+"""Site properties xml adapter and setup handler unit tests.
$Id$
"""
@@ -18,11 +18,17 @@
import unittest
import Testing
+from Products.Five import zcml
+
+from Products.GenericSetup.testing import BodyAdapterTestCase
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
+
from Products.CMFCore.tests.base.testcase import PlacelessSetup
-from Products.GenericSetup.testing import NodeAdapterTestCase
-
-_PROPERTIES_XML = """\
+_PROPERTIES_BODY = """\
+<?xml version="1.0"?>
<site>
<property name="title">Foo</property>
<property name="foo_string" type="string">foo</property>
@@ -30,14 +36,35 @@
</site>
"""
+_EMPTY_EXPORT = """\
+<?xml version="1.0" ?>
+<site>
+ <property name="title"/>
+</site>
+"""
-class PropertiesNodeAdapterTests(PlacelessSetup, NodeAdapterTestCase):
+_NORMAL_EXPORT = """\
+<?xml version="1.0" ?>
+<site>
+ <property name="title"/>
+ <property name="foo" type="string">Foo</property>
+ <property name="bar" type="tokens">
+ <element value="Bar"/>
+ </property>
+ <property name="moo" type="tokens">
+ <element value="Moo"/>
+ </property>
+</site>
+"""
+
+class PropertiesXMLAdapterTests(BodyAdapterTestCase):
+
def _getTargetClass(self):
from Products.CMFCore.exportimport.properties \
- import PropertiesNodeAdapter
+ import PropertiesXMLAdapter
- return PropertiesNodeAdapter
+ return PropertiesXMLAdapter
def _populate(self, obj):
obj._setPropValue('title', 'Foo')
@@ -45,22 +72,166 @@
obj._setProperty('foo_boolean', False, 'boolean')
def setUp(self):
+ import Products.CMFCore.exportimport
from Products.CMFCore.PortalObject import PortalObjectBase
+
+ BodyAdapterTestCase.setUp(self)
+ zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
+
+ self._obj = PortalObjectBase('foo_site')
+ self._BODY = _PROPERTIES_BODY
+
+
+class _SitePropertiesSetup(PlacelessSetup, BaseRegistryTests):
+
+ def _initSite(self, foo=2, bar=2):
+ from Products.CMFCore.PortalObject import PortalObjectBase
+
+ self.root.site = PortalObjectBase('foo_site')
+ site = self.root.site
+
+ if foo > 0:
+ site._setProperty('foo', '', 'string')
+ if foo > 1:
+ site._updateProperty('foo', 'Foo')
+
+ if bar > 0:
+ site._setProperty( 'bar', (), 'tokens' )
+ site._setProperty( 'moo', (), 'tokens' )
+ if bar > 1:
+ site._updateProperty( 'bar', ('Bar',) )
+ site.moo = ['Moo']
+
+ return site
+
+ def setUp(self):
import Products.CMFCore.exportimport
- import Products.Five
- from Products.Five import zcml
PlacelessSetup.setUp(self)
+ BaseRegistryTests.setUp(self)
zcml.load_config('meta.zcml', Products.Five)
zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
- self._obj = PortalObjectBase('foo_site')
- self._XML = _PROPERTIES_XML
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
+class exportSitePropertiesTests(_SitePropertiesSetup):
+
+ def test_empty(self):
+ from Products.CMFCore.exportimport.properties \
+ import exportSiteProperties
+
+ site = self._initSite(0, 0)
+ context = DummyExportContext(site)
+ exportSiteProperties(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'properties.xml')
+ self._compareDOM(text, _EMPTY_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+ def test_normal(self):
+ from Products.CMFCore.exportimport.properties \
+ import exportSiteProperties
+
+ site = self._initSite()
+ context = DummyExportContext( site )
+ exportSiteProperties(context)
+
+ self.assertEqual(len(context._wrote), 1)
+ filename, text, content_type = context._wrote[0]
+ self.assertEqual(filename, 'properties.xml')
+ self._compareDOM(text, _NORMAL_EXPORT)
+ self.assertEqual(content_type, 'text/xml')
+
+
+class importSitePropertiesTests(_SitePropertiesSetup):
+
+ def test_empty_default_purge(self):
+ from Products.CMFCore.exportimport.properties \
+ import importSiteProperties
+
+ site = self._initSite()
+
+ self.assertEqual( len( site.propertyIds() ), 4 )
+ self.failUnless( 'foo' in site.propertyIds() )
+ self.assertEqual( site.getProperty('foo'), 'Foo' )
+ self.failUnless( 'bar' in site.propertyIds() )
+ self.assertEqual( site.getProperty('bar'), ('Bar',) )
+
+ context = DummyImportContext(site)
+ context._files['properties.xml'] = _EMPTY_EXPORT
+ importSiteProperties(context)
+
+ self.assertEqual( len( site.propertyIds() ), 1 )
+
+ def test_empty_explicit_purge(self):
+ from Products.CMFCore.exportimport.properties \
+ import importSiteProperties
+
+ site = self._initSite()
+
+ self.assertEqual( len( site.propertyIds() ), 4 )
+ self.failUnless( 'foo' in site.propertyIds() )
+ self.assertEqual( site.getProperty('foo'), 'Foo' )
+ self.failUnless( 'bar' in site.propertyIds() )
+ self.assertEqual( site.getProperty('bar'), ('Bar',) )
+
+ context = DummyImportContext(site, True)
+ context._files['properties.xml'] = _EMPTY_EXPORT
+ importSiteProperties(context)
+
+ self.assertEqual( len( site.propertyIds() ), 1 )
+
+ def test_empty_skip_purge(self):
+ from Products.CMFCore.exportimport.properties \
+ import importSiteProperties
+
+ site = self._initSite()
+
+ self.assertEqual( len( site.propertyIds() ), 4 )
+ self.failUnless( 'foo' in site.propertyIds() )
+ self.assertEqual( site.getProperty('foo'), 'Foo' )
+ self.failUnless( 'bar' in site.propertyIds() )
+ self.assertEqual( site.getProperty('bar'), ('Bar',) )
+
+ context = DummyImportContext(site, False)
+ context._files['properties.xml'] = _EMPTY_EXPORT
+ importSiteProperties(context)
+
+ self.assertEqual( len( site.propertyIds() ), 4 )
+ self.failUnless( 'foo' in site.propertyIds() )
+ self.assertEqual( site.getProperty('foo'), 'Foo' )
+ self.failUnless( 'bar' in site.propertyIds() )
+ self.assertEqual( site.getProperty('bar'), ('Bar',) )
+
+ def test_normal(self):
+ from Products.CMFCore.exportimport.properties \
+ import importSiteProperties
+
+ site = self._initSite(0,0)
+
+ self.assertEqual( len( site.propertyIds() ), 1 )
+
+ context = DummyImportContext(site)
+ context._files['properties.xml'] = _NORMAL_EXPORT
+ importSiteProperties(context)
+
+ self.assertEqual( len( site.propertyIds() ), 4 )
+ self.failUnless( 'foo' in site.propertyIds() )
+ self.assertEqual( site.getProperty('foo'), 'Foo' )
+ self.failUnless( 'bar' in site.propertyIds() )
+ self.assertEqual( site.getProperty('bar'), ('Bar',) )
+
+
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(PropertiesNodeAdapterTests),
+ unittest.makeSuite(PropertiesXMLAdapterTests),
+ unittest.makeSuite(exportSitePropertiesTests),
+ unittest.makeSuite(importSitePropertiesTests),
))
if __name__ == '__main__':
Modified: CMF/trunk/CMFCore/exportimport/tests/test_skins.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_skins.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/tests/test_skins.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -27,8 +27,6 @@
from Products.Five import zcml
from zope.interface import implements
-from Products.CMFCore.interfaces import ISkinsTool
-from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.GenericSetup.testing import BodyAdapterTestCase
from Products.GenericSetup.testing import NodeAdapterTestCase
from Products.GenericSetup.tests.common import BaseRegistryTests
@@ -36,6 +34,9 @@
from Products.GenericSetup.tests.common import DummyExportContext
from Products.GenericSetup.tests.common import DummyImportContext
+from Products.CMFCore.interfaces import ISkinsTool
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
+
_TESTS_PATH = os.path.split(__file__)[0]
_DIRECTORYVIEW_XML = """\
@@ -352,7 +353,7 @@
class exportSkinsToolTests(_SkinsSetup):
def test_empty(self):
- from Products.CMFSetup.skins import exportSkinsTool
+ from Products.CMFCore.exportimport.skins import exportSkinsTool
site = self._initSite()
context = DummyExportContext(site)
@@ -365,7 +366,7 @@
self.assertEqual(content_type, 'text/xml')
def test_normal(self):
- from Products.CMFSetup.skins import exportSkinsTool
+ from Products.CMFCore.exportimport.skins import exportSkinsTool
_IDS = ('one', 'two', 'three')
_PATHS = {'basic': 'one', 'fancy': 'three, two, one'}
@@ -397,7 +398,7 @@
_NORMAL_EXPORT = _NORMAL_EXPORT
def test_empty_default_purge(self):
- from Products.CMFSetup.skins import importSkinsTool
+ from Products.CMFCore.exportimport.skins import importSkinsTool
_IDS = ('one', 'two', 'three')
_PATHS = {'basic': 'one', 'fancy': 'three, two, one'}
@@ -422,7 +423,7 @@
self.assertEqual(len(skins_tool.objectItems()), 0)
def test_empty_explicit_purge(self):
- from Products.CMFSetup.skins import importSkinsTool
+ from Products.CMFCore.exportimport.skins import importSkinsTool
_IDS = ('one', 'two', 'three')
_PATHS = {'basic': 'one', 'fancy': 'three, two, one'}
@@ -447,7 +448,7 @@
self.assertEqual(len(skins_tool.objectItems()), 0)
def test_empty_skip_purge(self):
- from Products.CMFSetup.skins import importSkinsTool
+ from Products.CMFCore.exportimport.skins import importSkinsTool
_IDS = ('one', 'two', 'three')
_PATHS = {'basic': 'one', 'fancy': 'three, two, one'}
@@ -472,7 +473,7 @@
self.assertEqual(len(skins_tool.objectItems()), 3)
def test_normal(self):
- from Products.CMFSetup.skins import importSkinsTool
+ from Products.CMFCore.exportimport.skins import importSkinsTool
site = self._initSite()
skins_tool = site.portal_skins
@@ -494,7 +495,7 @@
self.assertEqual(len(skins_tool.objectItems()), 3)
def test_fragment_skip_purge(self):
- from Products.CMFSetup.skins import importSkinsTool
+ from Products.CMFCore.exportimport.skins import importSkinsTool
_IDS = ('one', 'two')
_PATHS = {'basic': 'one', 'fancy': 'two,one'}
@@ -539,7 +540,7 @@
self.assertEqual(len(skins_tool.objectItems()), 4)
def test_fragment3_skip_purge(self):
- from Products.CMFSetup.skins import importSkinsTool
+ from Products.CMFCore.exportimport.skins import importSkinsTool
_IDS = ('one', 'two')
_PATHS = {'basic': 'one', 'fancy': 'two,one'}
@@ -571,7 +572,7 @@
self.assertEqual(len(skins_tool.objectItems()), 4)
def test_fragment4_removal(self):
- from Products.CMFSetup.skins import importSkinsTool
+ from Products.CMFCore.exportimport.skins import importSkinsTool
_IDS = ('one', 'two')
_PATHS = {'basic': 'one', 'fancy': 'two,one'}
Modified: CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -22,6 +22,11 @@
from OFS.Folder import Folder
from Products.Five import zcml
+from Products.GenericSetup.testing import BodyAdapterTestCase
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
+
from Products.CMFCore.permissions import View
from Products.CMFCore.permissions import AccessContentsInformation
from Products.CMFCore.permissions import ModifyPortalContent
@@ -29,12 +34,7 @@
from Products.CMFCore.TypesTool import FactoryTypeInformation
from Products.CMFCore.TypesTool import ScriptableTypeInformation
from Products.CMFCore.TypesTool import TypesTool
-from Products.GenericSetup.testing import BodyAdapterTestCase
-from Products.GenericSetup.tests.common import BaseRegistryTests
-from Products.GenericSetup.tests.common import DummyExportContext
-from Products.GenericSetup.tests.common import DummyImportContext
-
_FTI_BODY = """\
<?xml version="1.0"?>
<object name="foo_fti" meta_type="Factory-based Type Information"
@@ -66,103 +66,6 @@
</object>
"""
-
-class TypeInformationXMLAdapterTests(BodyAdapterTestCase):
-
- def _getTargetClass(self):
- from Products.CMFCore.exportimport.typeinfo \
- import TypeInformationXMLAdapter
-
- return TypeInformationXMLAdapter
-
- def _populate(self, obj):
- obj.addAction('foo_action', 'Foo', 'string:${object_url}/foo',
- 'python:1', (), 'Bar')
-
- def _verifyImport(self, obj):
- self.assertEqual(type(obj._aliases), dict)
- self.assertEqual(obj._aliases, {'(Default)': 'foo', 'view': 'foo'})
- self.assertEqual(type(obj._aliases['view']), str)
- self.assertEqual(obj._aliases['view'], 'foo')
- self.assertEqual(type(obj._actions), tuple)
- self.assertEqual(type(obj._actions[0].id), str)
- self.assertEqual(obj._actions[0].id, 'foo_action')
- self.assertEqual(type(obj._actions[0].title), str)
- self.assertEqual(obj._actions[0].title, 'Foo')
- self.assertEqual(type(obj._actions[0].description), str)
- self.assertEqual(obj._actions[0].description, '')
- self.assertEqual(type(obj._actions[0].category), str)
- self.assertEqual(obj._actions[0].category, 'Bar')
- self.assertEqual(type(obj._actions[0].condition.text), str)
- self.assertEqual(obj._actions[0].condition.text, 'python:1')
-
- def setUp(self):
- import Products.CMFCore
- from Products.CMFCore.TypesTool import FactoryTypeInformation
-
- BodyAdapterTestCase.setUp(self)
- zcml.load_config('configure.zcml', Products.CMFCore)
-
- self._obj = FactoryTypeInformation('foo_fti')
- self._BODY = _FTI_BODY
-
-
-class TypesToolXMLAdapterTests(BodyAdapterTestCase):
-
- def _getTargetClass(self):
- from Products.CMFCore.exportimport.typeinfo \
- import TypesToolXMLAdapter
-
- return TypesToolXMLAdapter
-
- def _populate(self, obj):
- from Products.CMFCore.TypesTool import FactoryTypeInformation
-
- obj._setObject('foo_type', FactoryTypeInformation('foo_type'))
-
- def setUp(self):
- import Products.CMFCore
- from Products.CMFCore.TypesTool import TypesTool
-
- BodyAdapterTestCase.setUp(self)
- zcml.load_config('configure.zcml', Products.CMFCore)
-
- self._obj = TypesTool()
- self._BODY = _TYPESTOOL_BODY
-
-
-class _TypeInfoSetup(PlacelessSetup, BaseRegistryTests):
-
- def _initSite(self, foo=0):
- self.root.site = Folder(id='site')
- site = self.root.site
- ttool = site.portal_types = TypesTool()
-
- if foo == 1:
- fti = _TI_LIST[0].copy()
- ttool._setObject(fti['id'], FactoryTypeInformation(**fti))
- sti = _TI_LIST[1].copy()
- ttool._setObject(sti['id'], ScriptableTypeInformation(**sti))
- elif foo == 2:
- fti = _TI_LIST_WITH_FILENAME[0].copy()
- ttool._setObject(fti['id'], FactoryTypeInformation(**fti))
- sti = _TI_LIST_WITH_FILENAME[1].copy()
- ttool._setObject(sti['id'], ScriptableTypeInformation(**sti))
-
- return site
-
- def setUp(self):
- PlacelessSetup.setUp(self)
- BaseRegistryTests.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('permissions.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.CMFCore)
-
- def tearDown(self):
- BaseRegistryTests.tearDown(self)
- PlacelessSetup.tearDown(self)
-
-
_TI_LIST = ({
'id': 'foo',
'title': 'Foo',
@@ -484,10 +387,106 @@
"""
+class TypeInformationXMLAdapterTests(BodyAdapterTestCase):
+
+ def _getTargetClass(self):
+ from Products.CMFCore.exportimport.typeinfo \
+ import TypeInformationXMLAdapter
+
+ return TypeInformationXMLAdapter
+
+ def _populate(self, obj):
+ obj.addAction('foo_action', 'Foo', 'string:${object_url}/foo',
+ 'python:1', (), 'Bar')
+
+ def _verifyImport(self, obj):
+ self.assertEqual(type(obj._aliases), dict)
+ self.assertEqual(obj._aliases, {'(Default)': 'foo', 'view': 'foo'})
+ self.assertEqual(type(obj._aliases['view']), str)
+ self.assertEqual(obj._aliases['view'], 'foo')
+ self.assertEqual(type(obj._actions), tuple)
+ self.assertEqual(type(obj._actions[0].id), str)
+ self.assertEqual(obj._actions[0].id, 'foo_action')
+ self.assertEqual(type(obj._actions[0].title), str)
+ self.assertEqual(obj._actions[0].title, 'Foo')
+ self.assertEqual(type(obj._actions[0].description), str)
+ self.assertEqual(obj._actions[0].description, '')
+ self.assertEqual(type(obj._actions[0].category), str)
+ self.assertEqual(obj._actions[0].category, 'Bar')
+ self.assertEqual(type(obj._actions[0].condition.text), str)
+ self.assertEqual(obj._actions[0].condition.text, 'python:1')
+
+ def setUp(self):
+ import Products.CMFCore
+ from Products.CMFCore.TypesTool import FactoryTypeInformation
+
+ BodyAdapterTestCase.setUp(self)
+ zcml.load_config('configure.zcml', Products.CMFCore)
+
+ self._obj = FactoryTypeInformation('foo_fti')
+ self._BODY = _FTI_BODY
+
+
+class TypesToolXMLAdapterTests(BodyAdapterTestCase):
+
+ def _getTargetClass(self):
+ from Products.CMFCore.exportimport.typeinfo \
+ import TypesToolXMLAdapter
+
+ return TypesToolXMLAdapter
+
+ def _populate(self, obj):
+ from Products.CMFCore.TypesTool import FactoryTypeInformation
+
+ obj._setObject('foo_type', FactoryTypeInformation('foo_type'))
+
+ def setUp(self):
+ import Products.CMFCore
+ from Products.CMFCore.TypesTool import TypesTool
+
+ BodyAdapterTestCase.setUp(self)
+ zcml.load_config('configure.zcml', Products.CMFCore)
+
+ self._obj = TypesTool()
+ self._BODY = _TYPESTOOL_BODY
+
+
+class _TypeInfoSetup(PlacelessSetup, BaseRegistryTests):
+
+ def _initSite(self, foo=0):
+ self.root.site = Folder(id='site')
+ site = self.root.site
+ ttool = site.portal_types = TypesTool()
+
+ if foo == 1:
+ fti = _TI_LIST[0].copy()
+ ttool._setObject(fti['id'], FactoryTypeInformation(**fti))
+ sti = _TI_LIST[1].copy()
+ ttool._setObject(sti['id'], ScriptableTypeInformation(**sti))
+ elif foo == 2:
+ fti = _TI_LIST_WITH_FILENAME[0].copy()
+ ttool._setObject(fti['id'], FactoryTypeInformation(**fti))
+ sti = _TI_LIST_WITH_FILENAME[1].copy()
+ ttool._setObject(sti['id'], ScriptableTypeInformation(**sti))
+
+ return site
+
+ def setUp(self):
+ PlacelessSetup.setUp(self)
+ BaseRegistryTests.setUp(self)
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('permissions.zcml', Products.Five)
+ zcml.load_config('configure.zcml', Products.CMFCore)
+
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
+
+
class exportTypesToolTests(_TypeInfoSetup):
def test_empty(self):
- from Products.CMFSetup.typeinfo import exportTypesTool
+ from Products.CMFCore.exportimport.typeinfo import exportTypesTool
site = self._initSite()
context = DummyExportContext(site)
@@ -500,7 +499,7 @@
self.assertEqual(content_type, 'text/xml')
def test_normal(self):
- from Products.CMFSetup.typeinfo import exportTypesTool
+ from Products.CMFCore.exportimport.typeinfo import exportTypesTool
site = self._initSite(1)
context = DummyExportContext(site)
@@ -523,24 +522,21 @@
self.assertEqual(content_type, 'text/xml')
def test_with_filenames(self):
- from Products.CMFSetup.typeinfo import exportTypesTool
+ from Products.CMFCore.exportimport.typeinfo import exportTypesTool
site = self._initSite(2)
context = DummyExportContext(site)
exportTypesTool(context)
self.assertEqual(len(context._wrote), 3)
-
filename, text, content_type = context._wrote[0]
self.assertEqual(filename, 'typestool.xml')
self._compareDOM(text, _FILENAME_EXPORT)
self.assertEqual(content_type, 'text/xml')
-
filename, text, content_type = context._wrote[2]
self.assertEqual(filename, 'types/bar_object.xml')
self._compareDOM(text, _BAR_EXPORT % 'bar object')
self.assertEqual(content_type, 'text/xml')
-
filename, text, content_type = context._wrote[1]
self.assertEqual(filename, 'types/foo_object.xml')
self._compareDOM(text, _FOO_EXPORT % 'foo object')
@@ -554,7 +550,7 @@
_NORMAL_TOOL_EXPORT = _NORMAL_TOOL_EXPORT
def test_empty_default_purge(self):
- from Products.CMFSetup.typeinfo import importTypesTool
+ from Products.CMFCore.exportimport.typeinfo import importTypesTool
site = self._initSite(1)
tool = site.portal_types
@@ -568,7 +564,7 @@
self.assertEqual(len(tool.objectIds()), 0)
def test_empty_explicit_purge(self):
- from Products.CMFSetup.typeinfo import importTypesTool
+ from Products.CMFCore.exportimport.typeinfo import importTypesTool
site = self._initSite(1)
tool = site.portal_types
@@ -582,7 +578,7 @@
self.assertEqual(len(tool.objectIds()), 0)
def test_empty_skip_purge(self):
- from Products.CMFSetup.typeinfo import importTypesTool
+ from Products.CMFCore.exportimport.typeinfo import importTypesTool
site = self._initSite(1)
tool = site.portal_types
@@ -596,7 +592,7 @@
self.assertEqual(len(tool.objectIds()), 2)
def test_normal(self):
- from Products.CMFSetup.typeinfo import importTypesTool
+ from Products.CMFCore.exportimport.typeinfo import importTypesTool
site = self._initSite()
tool = site.portal_types
@@ -614,8 +610,8 @@
self.failUnless('bar' in tool.objectIds())
def test_old_xml(self):
- from Products.CMFSetup.typeinfo import exportTypesTool
- from Products.CMFSetup.typeinfo import importTypesTool
+ from Products.CMFCore.exportimport.typeinfo import exportTypesTool
+ from Products.CMFCore.exportimport.typeinfo import importTypesTool
site = self._initSite()
tool = site.portal_types
@@ -641,7 +637,7 @@
self.assertEqual(content_type, 'text/xml')
def test_with_filenames(self):
- from Products.CMFSetup.typeinfo import importTypesTool
+ from Products.CMFCore.exportimport.typeinfo import importTypesTool
site = self._initSite()
tool = site.portal_types
@@ -659,7 +655,7 @@
self.failUnless('bar object' in tool.objectIds())
def test_normal_update(self):
- from Products.CMFSetup.typeinfo import importTypesTool
+ from Products.CMFCore.exportimport.typeinfo import importTypesTool
site = self._initSite()
tool = site.portal_types
Modified: CMF/trunk/CMFCore/exportimport/tests/test_workflow.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_workflow.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/tests/test_workflow.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -24,15 +24,16 @@
from Products.Five import zcml
from zope.interface import implements
-from Products.CMFCore.interfaces import IWorkflowDefinition
-from Products.CMFCore.interfaces import IWorkflowTool
-from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.GenericSetup.testing import BodyAdapterTestCase
from Products.GenericSetup.tests.common import BaseRegistryTests
from Products.GenericSetup.tests.common import DummyExportContext
from Products.GenericSetup.tests.common import DummyImportContext
from Products.GenericSetup.utils import BodyAdapterBase
+from Products.CMFCore.interfaces import IWorkflowDefinition
+from Products.CMFCore.interfaces import IWorkflowTool
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
+
_DUMMY_ZCML = """\
<configure
xmlns="http://namespaces.zope.org/zope"
Modified: CMF/trunk/CMFCore/exportimport/typeinfo.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/typeinfo.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFCore/exportimport/typeinfo.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -33,18 +33,17 @@
from Products.CMFCore.interfaces import ITypesTool
from Products.CMFCore.utils import getToolByName
-
_FILENAME = 'typestool.xml'
class TypeInformationXMLAdapter(XMLAdapterBase, PropertyManagerHelpers):
- """Node im- and exporter for TypeInformation.
+ """XML im- and exporter for TypeInformation.
"""
__used_for__ = ITypeInformation
- _LOGGER_ID = 'typestool'
+ _LOGGER_ID = 'types'
def exportNode(self, doc):
"""Export the object as a DOM node.
@@ -201,12 +200,12 @@
class TypesToolXMLAdapter(XMLAdapterBase, ObjectManagerHelpers,
PropertyManagerHelpers):
- """Node im- and exporter for TypesTool.
+ """XML im- and exporter for TypesTool.
"""
__used_for__ = ITypesTool
- _LOGGER_ID = 'typestool'
+ _LOGGER_ID = 'types'
def exportNode(self, doc):
"""Export the object as a DOM node.
@@ -263,7 +262,7 @@
"""Import types tool and content types from XML files.
"""
site = context.getSite()
- logger = context.getLogger('typestool')
+ logger = context.getLogger('types')
tool = getToolByName(site, 'portal_types')
body = context.readDataFile(_FILENAME)
@@ -283,8 +282,8 @@
"""Export types tool content types as a set of XML files.
"""
site = context.getSite()
- logger = context.getLogger('typestool')
- tool = getToolByName(site, 'portal_types')
+ logger = context.getLogger('types')
+ tool = getToolByName(site, 'portal_types', None)
if tool is None:
logger.info('Nothing to export.')
return
Modified: CMF/trunk/CMFDefault/profiles/default/export_steps.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/export_steps.xml 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFDefault/profiles/default/export_steps.xml 2005-11-29 19:44:07 UTC (rev 40413)
@@ -6,32 +6,32 @@
Export actions tool's action providers and their actions.
</export-step>
<export-step id="caching_policy_mgr"
- handler="Products.CMFSetup.cachingpolicymgr.exportCachingPolicyManager"
+ handler="Products.CMFCore.exportimport.cachingpolicymgr.exportCachingPolicyManager"
title="Caching Policies">
Export caching policy manager's policies.
</export-step>
<export-step id="catalog"
- handler="Products.CMFSetup.catalog.exportCatalogTool"
+ handler="Products.CMFCore.exportimport.catalog.exportCatalogTool"
title="Catalog Tool">
Export catalog tool's sub-objects, indexes and columns.
</export-step>
<export-step id="content_type_registry"
- handler="Products.CMFSetup.contenttyperegistry.exportContentTypeRegistry"
+ handler="Products.CMFCore.exportimport.contenttyperegistry.exportContentTypeRegistry"
title="Content Type Registry">
Export content type registry's predicates / bindings.
</export-step>
<export-step id="cookieauth"
- handler="Products.CMFSetup.cookieauth.exportCookieCrumbler"
+ handler="Products.CMFCore.exportimport.cookieauth.exportCookieCrumbler"
title="Cookie Authentication">
Export cookie crumbler settings
</export-step>
<export-step id="mailhost"
- handler="Products.CMFSetup.mailhost.exportMailHost"
+ handler="Products.CMFCore.exportimport.mailhost.exportMailHost"
title="MailHost">
Export the mailhost's settings and properties
</export-step>
<export-step id="properties"
- handler="Products.CMFSetup.properties.exportSiteProperties"
+ handler="Products.CMFCore.exportimport.properties.exportSiteProperties"
title="Site Properties">
Export site properties.
</export-step>
Modified: CMF/trunk/CMFDefault/profiles/default/import_steps.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/import_steps.xml 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFDefault/profiles/default/import_steps.xml 2005-11-29 19:44:07 UTC (rev 40413)
@@ -7,39 +7,39 @@
Import actions tool's action providers and their actions.
</import-step>
<import-step id="caching_policy_mgr" version="20051011-01"
- handler="Products.CMFSetup.cachingpolicymgr.importCachingPolicyManager"
+ handler="Products.CMFCore.exportimport.cachingpolicymgr.importCachingPolicyManager"
title="Caching Policies">
<dependency step="toolset"/>
Import caching policy manager's policies.
</import-step>
<import-step id="catalog" version="20050929-01"
- handler="Products.CMFSetup.catalog.importCatalogTool"
+ handler="Products.CMFCore.exportimport.catalog.importCatalogTool"
title="Catalog Tool">
<dependency step="toolset"/>
Import catalog tool's sub-objects, indexes and columns.
</import-step>
<import-step id="content_type_registry"
version="20051013-01"
- handler="Products.CMFSetup.contenttyperegistry.importContentTypeRegistry"
+ handler="Products.CMFCore.exportimport.contenttyperegistry.importContentTypeRegistry"
title="Content Type Registry">
<dependency step="toolset"/>
Import content type registry's predicates and bindings.
</import-step>
<import-step id="cookie_authentication"
version="20050903-01"
- handler="Products.CMFSetup.cookieauth.importCookieCrumbler"
+ handler="Products.CMFCore.exportimport.cookieauth.importCookieCrumbler"
title="Cookie Authentication">
<dependency step="toolset"/>
Import cookie crumbler settings
</import-step>
<import-step id="mailhost" version="20050803-01"
- handler="Products.CMFSetup.mailhost.importMailHost"
+ handler="Products.CMFCore.exportimport.mailhost.importMailHost"
title="MailHost">
<dependency step="toolset"/>
Import mailhost settings
</import-step>
<import-step id="properties" version="20041215-01"
- handler="Products.CMFSetup.properties.importSiteProperties"
+ handler="Products.CMFCore.exportimport.properties.importSiteProperties"
title="Site Properties">
Import site properties.
</import-step>
Modified: CMF/trunk/CMFSetup/cachingpolicymgr.py
===================================================================
--- CMF/trunk/CMFSetup/cachingpolicymgr.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFSetup/cachingpolicymgr.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -10,54 +10,12 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""CachingPolicyManager setup handlers.
+"""Caching policy manager setup handlers.
$Id$
"""
-from xml.dom.minidom import parseString
-
-from Products.CMFCore.utils import getToolByName
-from Products.GenericSetup.interfaces import INodeExporter
-from Products.GenericSetup.interfaces import INodeImporter
-from Products.GenericSetup.interfaces import PURGE, UPDATE
-from Products.GenericSetup.utils import PrettyDocument
-
-_FILENAME = 'cachingpolicymgr.xml'
-
-
-def importCachingPolicyManager(context):
- """ Import caching policy manager settings from an XML file.
- """
- site = context.getSite()
- mode = context.shouldPurge() and PURGE or UPDATE
- cptool = getToolByName(site, 'caching_policy_manager', None)
-
- body = context.readDataFile(_FILENAME)
- if body is None:
- return 'Caching policy manager: Nothing to import.'
-
- importer = INodeImporter(cptool, None)
- if importer is None:
- return 'Caching policy manager: Import adapter misssing.'
-
- importer.importNode(parseString(body).documentElement, mode=mode)
- return 'Caching policy manager settings imported.'
-
-def exportCachingPolicyManager(context):
- """ Export caching policy manager settings as an XML file.
- """
- site = context.getSite()
-
- cptool = getToolByName(site, 'caching_policy_manager', None)
- if cptool is None:
- return 'Caching policy manager: Nothing to export.'
-
- exporter = INodeExporter(cptool)
- if exporter is None:
- return 'Caching policy manager: Export adapter misssing.'
-
- doc = PrettyDocument()
- doc.appendChild(exporter.exportNode(doc))
- context.writeDataFile(_FILENAME, doc.toprettyxml(' '), 'text/xml')
- return 'Caching policy manager settings exported.'
+from Products.CMFCore.exportimport.cachingpolicymgr \
+ import exportCachingPolicyManager
+from Products.CMFCore.exportimport.cachingpolicymgr \
+ import importCachingPolicyManager
Modified: CMF/trunk/CMFSetup/catalog.py
===================================================================
--- CMF/trunk/CMFSetup/catalog.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFSetup/catalog.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -15,49 +15,5 @@
$Id$
"""
-from xml.dom.minidom import parseString
-
-from Products.CMFCore.utils import getToolByName
-from Products.GenericSetup.interfaces import INodeExporter
-from Products.GenericSetup.interfaces import INodeImporter
-from Products.GenericSetup.interfaces import PURGE, UPDATE
-from Products.GenericSetup.utils import PrettyDocument
-
-_FILENAME = 'catalog.xml'
-
-
-def importCatalogTool(context):
- """ Import catalog tool.
- """
- site = context.getSite()
- mode = context.shouldPurge() and PURGE or UPDATE
- ctool = getToolByName(site, 'portal_catalog')
-
- body = context.readDataFile(_FILENAME)
- if body is None:
- return 'Catalog tool: Nothing to import.'
-
- importer = INodeImporter(ctool, None)
- if importer is None:
- return 'Catalog tool: Import adapter misssing.'
-
- importer.importNode(parseString(body).documentElement, mode=mode)
- return 'Catalog tool imported.'
-
-def exportCatalogTool(context):
- """ Export catalog tool.
- """
- site = context.getSite()
-
- ctool = getToolByName(site, 'portal_catalog', None)
- if ctool is None:
- return 'Catalog tool: Nothing to export.'
-
- exporter = INodeExporter(ctool)
- if exporter is None:
- return 'Catalog tool: Export adapter misssing.'
-
- doc = PrettyDocument()
- doc.appendChild(exporter.exportNode(doc))
- context.writeDataFile(_FILENAME, doc.toprettyxml(' '), 'text/xml')
- return 'Catalog tool exported.'
+from Products.CMFCore.exportimport.catalog import exportCatalogTool
+from Products.CMFCore.exportimport.catalog import importCatalogTool
Modified: CMF/trunk/CMFSetup/contenttyperegistry.py
===================================================================
--- CMF/trunk/CMFSetup/contenttyperegistry.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFSetup/contenttyperegistry.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -10,54 +10,12 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""ContentTypeRegistry setup handlers.
+"""Content type registry setup handlers.
$Id$
"""
-from xml.dom.minidom import parseString
-
-from Products.CMFCore.utils import getToolByName
-from Products.GenericSetup.interfaces import INodeExporter
-from Products.GenericSetup.interfaces import INodeImporter
-from Products.GenericSetup.interfaces import PURGE, UPDATE
-from Products.GenericSetup.utils import PrettyDocument
-
-_FILENAME = 'contenttyperegistry.xml'
-
-
-def importContentTypeRegistry(context):
- """ Import content type registry settings from an XML file.
- """
- site = context.getSite()
- mode = context.shouldPurge() and PURGE or UPDATE
- ctr = getToolByName(site, 'content_type_registry', None)
-
- body = context.readDataFile(_FILENAME)
- if body is None:
- return 'Content type registry: Nothing to import.'
-
- importer = INodeImporter(ctr, None)
- if importer is None:
- return 'Content type registry: Import adapter misssing.'
-
- importer.importNode(parseString(body).documentElement, mode=mode)
- return 'Content type registry settings imported.'
-
-def exportContentTypeRegistry(context):
- """ Export content type registry settings as an XML file.
- """
- site = context.getSite()
-
- ctr = getToolByName(site, 'content_type_registry', None)
- if ctr is None:
- return 'Content type registry: Nothing to export.'
-
- exporter = INodeExporter(ctr)
- if exporter is None:
- return 'Content type registry: Export adapter misssing.'
-
- doc = PrettyDocument()
- doc.appendChild(exporter.exportNode(doc))
- context.writeDataFile(_FILENAME, doc.toprettyxml(' '), 'text/xml')
- return 'Content type registry settings exported.'
+from Products.CMFCore.exportimport.contenttyperegistry \
+ import exportContentTypeRegistry
+from Products.CMFCore.exportimport.contenttyperegistry \
+ import importContentTypeRegistry
Modified: CMF/trunk/CMFSetup/cookieauth.py
===================================================================
--- CMF/trunk/CMFSetup/cookieauth.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFSetup/cookieauth.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -15,49 +15,5 @@
$Id$
"""
-from xml.dom.minidom import parseString
-
-from Products.CMFCore.utils import getToolByName
-from Products.GenericSetup.interfaces import INodeExporter
-from Products.GenericSetup.interfaces import INodeImporter
-from Products.GenericSetup.interfaces import PURGE, UPDATE
-from Products.GenericSetup.utils import PrettyDocument
-
-_FILENAME = 'cookieauth.xml'
-
-
-def importCookieCrumbler(context):
- """ Import cookie crumbler settings from an XML file.
- """
- site = context.getSite()
- mode = context.shouldPurge() and PURGE or UPDATE
- cctool = getToolByName(site, 'cookie_authentication')
-
- body = context.readDataFile(_FILENAME)
- if body is None:
- return 'Cookie crumbler: Nothing to import.'
-
- importer = INodeImporter(cctool, None)
- if importer is None:
- return 'Cookie crumbler: Import adapter misssing.'
-
- importer.importNode(parseString(body).documentElement, mode=mode)
- return 'Cookie crumbler settings imported.'
-
-def exportCookieCrumbler(context):
- """ Export cookie crumbler settings as an XML file.
- """
- site = context.getSite()
-
- cctool = getToolByName(site, 'cookie_authentication', None)
- if cctool is None:
- return 'Cookie crumbler: Nothing to export.'
-
- exporter = INodeExporter(cctool)
- if exporter is None:
- return 'Cookie crumbler: Export adapter misssing.'
-
- doc = PrettyDocument()
- doc.appendChild(exporter.exportNode(doc))
- context.writeDataFile(_FILENAME, doc.toprettyxml(' '), 'text/xml')
- return 'Cookie crumbler settings exported.'
+from Products.CMFCore.exportimport.cookieauth import exportCookieCrumbler
+from Products.CMFCore.exportimport.cookieauth import importCookieCrumbler
Modified: CMF/trunk/CMFSetup/mailhost.py
===================================================================
--- CMF/trunk/CMFSetup/mailhost.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFSetup/mailhost.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -15,49 +15,5 @@
$Id$
"""
-from xml.dom.minidom import parseString
-
-from Products.CMFCore.utils import getToolByName
-from Products.GenericSetup.interfaces import INodeExporter
-from Products.GenericSetup.interfaces import INodeImporter
-from Products.GenericSetup.interfaces import PURGE, UPDATE
-from Products.GenericSetup.utils import PrettyDocument
-
-_FILENAME = 'mailhost.xml'
-
-
-def importMailHost(context):
- """ Import mailhost settings from an XML file.
- """
- site = context.getSite()
- mode = context.shouldPurge() and PURGE or UPDATE
- mailhost = getToolByName(site, 'MailHost')
-
- body = context.readDataFile(_FILENAME)
- if body is None:
- return 'Mailhost: Nothing to import.'
-
- importer = INodeImporter(mailhost, None)
- if importer is None:
- return 'Mailhost: Import adapter misssing.'
-
- importer.importNode(parseString(body).documentElement, mode=mode)
- return 'Mailhost settings imported.'
-
-def exportMailHost(context):
- """ Export mailhost settings as an XML file.
- """
- site = context.getSite()
-
- mailhost = getToolByName(site, 'MailHost', None)
- if mailhost is None:
- return 'Mailhost: Nothing to export.'
-
- exporter = INodeExporter(mailhost)
- if exporter is None:
- return 'Mailhost: Export adapter misssing.'
-
- doc = PrettyDocument()
- doc.appendChild(exporter.exportNode(doc))
- context.writeDataFile(_FILENAME, doc.toprettyxml(' '), 'text/xml')
- return 'Mailhost settings exported.'
+from Products.CMFCore.exportimport.mailhost import exportMailHost
+from Products.CMFCore.exportimport.mailhost import importMailHost
Modified: CMF/trunk/CMFSetup/properties.py
===================================================================
--- CMF/trunk/CMFSetup/properties.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFSetup/properties.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -15,43 +15,5 @@
$Id$
"""
-from xml.dom.minidom import parseString
-
-from Products.GenericSetup.interfaces import INodeExporter
-from Products.GenericSetup.interfaces import INodeImporter
-from Products.GenericSetup.interfaces import PURGE, UPDATE
-from Products.GenericSetup.utils import PrettyDocument
-
-_FILENAME = 'properties.xml'
-
-
-def importSiteProperties(context):
- """ Import site properties from an XML file.
- """
- site = context.getSite()
- mode = context.shouldPurge() and PURGE or UPDATE
-
- body = context.readDataFile(_FILENAME)
- if body is None:
- return 'Site properties: Nothing to import.'
-
- importer = INodeImporter(site, None)
- if importer is None:
- return 'Site properties: Import adapter misssing.'
-
- importer.importNode(parseString(body).documentElement, mode=mode)
- return 'Site properties imported.'
-
-def exportSiteProperties(context):
- """ Export site properties as an XML file.
- """
- site = context.getSite()
-
- exporter = INodeExporter(site)
- if exporter is None:
- return 'Site properties: Export adapter misssing.'
-
- doc = PrettyDocument()
- doc.appendChild(exporter.exportNode(doc))
- context.writeDataFile(_FILENAME, doc.toprettyxml(' '), 'text/xml')
- return 'Site properties exported.'
+from Products.CMFCore.exportimport.properties import exportSiteProperties
+from Products.CMFCore.exportimport.properties import importSiteProperties
Deleted: CMF/trunk/CMFSetup/tests/test_cachingpolicymgr.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_cachingpolicymgr.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFSetup/tests/test_cachingpolicymgr.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -1,177 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""CachingPolicyManager setup handler unit tests.
-
-$Id$
-"""
-
-import unittest
-import Testing
-
-import Products
-from Products.Five import zcml
-
-from Products.CMFCore.tests.base.testcase import PlacelessSetup
-from Products.GenericSetup.tests.common import BaseRegistryTests
-from Products.GenericSetup.tests.common import DummyExportContext
-from Products.GenericSetup.tests.common import DummyImportContext
-
-
-class _CachingPolicyManagerSetup(PlacelessSetup, BaseRegistryTests):
-
- POLICY_ID = 'policy_id'
- PREDICATE = "python:object.getId() == 'foo'"
- MTIME_FUNC = "object/modified"
- MAX_AGE_SECS = 60
- VARY = "Test"
- ETAG_FUNC = "object/getETag"
- S_MAX_AGE_SECS = 120
- PRE_CHECK = 42
- POST_CHECK = 43
-
- _EMPTY_EXPORT = """\
-<?xml version="1.0"?>
-<object name="caching_policy_manager" meta_type="CMF Caching Policy Manager"/>
-"""
-
- _WITH_POLICY_EXPORT = """\
-<?xml version="1.0"?>
-<object name="caching_policy_manager" meta_type="CMF Caching Policy Manager">
- <caching-policy name="%s" enable_304s="True"
- etag_func="%s" last_modified="False" max_age_secs="%d"
- mtime_func="%s" must_revalidate="True" no_cache="True"
- no_store="True" no_transform="True" post_check="%d" pre_check="%d"
- predicate="%s" private="True"
- proxy_revalidate="True" public="True" s_max_age_secs="%d" vary="%s"/>
-</object>
-""" % (POLICY_ID, ETAG_FUNC, MAX_AGE_SECS, MTIME_FUNC, POST_CHECK, PRE_CHECK,
- PREDICATE, S_MAX_AGE_SECS, VARY)
-
- def _initSite(self, with_policy=False):
- from OFS.Folder import Folder
- from Products.CMFCore.CachingPolicyManager import CachingPolicyManager
-
- self.root.site = Folder(id='site')
- site = self.root.site
- mgr = CachingPolicyManager()
- site._setObject( mgr.getId(), mgr )
-
- if with_policy:
- mgr.addPolicy( policy_id=self.POLICY_ID
- , predicate=self.PREDICATE
- , mtime_func=self.MTIME_FUNC
- , max_age_secs=self.MAX_AGE_SECS
- , no_cache=True
- , no_store=True
- , must_revalidate=True
- , vary=self.VARY
- , etag_func=self.ETAG_FUNC
- , s_max_age_secs=self.S_MAX_AGE_SECS
- , proxy_revalidate=True
- , public=True
- , private=True
- , no_transform=True
- , enable_304s=True
- , last_modified=False
- , pre_check=self.PRE_CHECK
- , post_check=self.POST_CHECK
- )
- return site
-
- def setUp(self):
- PlacelessSetup.setUp(self)
- BaseRegistryTests.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
-
- def tearDown(self):
- BaseRegistryTests.tearDown(self)
- PlacelessSetup.tearDown(self)
-
-
-class Test_exportCachingPolicyManager(_CachingPolicyManagerSetup):
-
- def test_empty(self):
- from Products.CMFSetup.cachingpolicymgr \
- import exportCachingPolicyManager
-
- site = self._initSite(with_policy=False)
- context = DummyExportContext(site)
- exportCachingPolicyManager(context)
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'cachingpolicymgr.xml')
- self._compareDOM(text, self._EMPTY_EXPORT)
- self.assertEqual(content_type, 'text/xml')
-
- def test_with_policy(self):
- from Products.CMFSetup.cachingpolicymgr \
- import exportCachingPolicyManager
-
- site = self._initSite(with_policy=True)
- context = DummyExportContext(site)
- exportCachingPolicyManager(context)
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'cachingpolicymgr.xml')
- self._compareDOM(text, self._WITH_POLICY_EXPORT)
- self.assertEqual(content_type, 'text/xml')
-
-
-class Test_importCachingPolicyManager(_CachingPolicyManagerSetup):
-
- def test_normal(self):
- from Products.CMFSetup.cachingpolicymgr \
- import importCachingPolicyManager
-
- site = self._initSite(with_policy=False)
- cpm = site.caching_policy_manager
- self.assertEqual(len(cpm.listPolicies()), 0)
-
- context = DummyImportContext(site)
- context._files['cachingpolicymgr.xml'] = self._WITH_POLICY_EXPORT
- importCachingPolicyManager(context)
-
- self.assertEqual(len(cpm.listPolicies()), 1)
- policy_id, policy = cpm.listPolicies()[0]
-
- self.assertEqual(policy.getPolicyId(), self.POLICY_ID)
- self.assertEqual(policy.getPredicate(), self.PREDICATE)
- self.assertEqual(policy.getMTimeFunc(), self.MTIME_FUNC)
- self.assertEqual(policy.getVary(), self.VARY)
- self.assertEqual(policy.getETagFunc(), self.ETAG_FUNC)
- self.assertEqual(policy.getMaxAgeSecs(), self.MAX_AGE_SECS)
- self.assertEqual(policy.getSMaxAgeSecs(), self.S_MAX_AGE_SECS)
- self.assertEqual(policy.getPreCheck(), self.PRE_CHECK)
- self.assertEqual(policy.getPostCheck(), self.POST_CHECK)
- self.assertEqual(policy.getLastModified(), False)
- self.assertEqual(policy.getNoCache(), True)
- self.assertEqual(policy.getNoStore(), True)
- self.assertEqual(policy.getMustRevalidate(), True)
- self.assertEqual(policy.getProxyRevalidate(), True)
- self.assertEqual(policy.getNoTransform(), True)
- self.assertEqual(policy.getPublic(), True)
- self.assertEqual(policy.getPrivate(), True)
- self.assertEqual(policy.getEnable304s(), True)
-
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(Test_exportCachingPolicyManager),
- unittest.makeSuite(Test_importCachingPolicyManager),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
Deleted: CMF/trunk/CMFSetup/tests/test_catalog.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_catalog.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFSetup/tests/test_catalog.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -1,239 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Catalog tool setup handler unit tests.
-
-$Id$
-"""
-
-import unittest
-import Testing
-
-import Products
-from OFS.Folder import Folder
-from Products.Five import zcml
-from Products.ZCTextIndex.Lexicon import CaseNormalizer
-from Products.ZCTextIndex.Lexicon import Splitter
-from Products.ZCTextIndex.Lexicon import StopWordRemover
-from Products.ZCTextIndex.ZCTextIndex import PLexicon
-
-from Products.CMFCore.CatalogTool import CatalogTool
-from Products.CMFCore.tests.base.testcase import PlacelessSetup
-from Products.GenericSetup.tests.common import BaseRegistryTests
-from Products.GenericSetup.tests.common import DummyExportContext
-from Products.GenericSetup.tests.common import DummyImportContext
-
-
-class _extra:
-
- pass
-
-
-class _CatalogToolSetup(PlacelessSetup, BaseRegistryTests):
-
- def _initSite(self, foo=2):
- site = self.root.site = Folder(id='site')
- ctool = site.portal_catalog = CatalogTool()
-
- for obj_id in ctool.objectIds():
- ctool._delObject(obj_id)
- for idx_id in ctool.indexes():
- ctool.delIndex(idx_id)
- for col in ctool.schema()[:]:
- ctool.delColumn(col)
-
- if foo > 0:
- ctool._setObject('foo_plexicon', PLexicon('foo_plexicon'))
- lex = ctool.foo_plexicon
- lex._pipeline = (Splitter(), CaseNormalizer(), StopWordRemover())
-
- extra = _extra()
- extra.lexicon_id = 'foo_plexicon'
- extra.index_type = 'Okapi BM25 Rank'
- ctool.addIndex('foo_zctext', 'ZCTextIndex', extra)
-
- ctool.addColumn('foo_zctext')
-
- return site
-
- def setUp(self):
- PlacelessSetup.setUp(self)
- BaseRegistryTests.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('configure.zcml',
- Products.GenericSetup.PluginIndexes)
- zcml.load_config('configure.zcml', Products.GenericSetup.ZCatalog)
- zcml.load_config('configure.zcml', Products.GenericSetup.ZCTextIndex)
-
- def tearDown(self):
- BaseRegistryTests.tearDown(self)
- PlacelessSetup.tearDown(self)
-
-_EMPTY_EXPORT = """\
-<?xml version="1.0"?>
-<object meta_type="CMF Catalog" name="portal_catalog">
- <property name="title"/>
-</object>
-"""
-
-_NORMAL_EXPORT = """\
-<?xml version="1.0"?>
-<object meta_type="CMF Catalog" name="portal_catalog">
- <property name="title"/>
- <object name="foo_plexicon" meta_type="ZCTextIndex Lexicon">
- <element name="Whitespace splitter" group="Word Splitter"/>
- <element name="Case Normalizer" group="Case Normalizer"/>
- <element name="Remove listed stop words only" group="Stop Words"/>
- </object>
- <index name="foo_zctext" meta_type="ZCTextIndex">
- <indexed_attr value="foo_zctext"/>
- <extra name="index_type" value="Okapi BM25 Rank"/>
- <extra name="lexicon_id" value="foo_plexicon"/>
- </index>
- <column value="foo_zctext"/>
-</object>
-"""
-
-_UPDATE_IMPORT = """\
-<?xml version="1.0"?>
-<object meta_type="CMF Catalog" name="portal_catalog">
- <index name="foo_date" meta_type="DateIndex">
- <property name="index_naive_time_as_local">True</property>
- </index>
- <column value="foo_date"/>
-</object>
-"""
-
-
-class Test_exportCatalogTool(_CatalogToolSetup):
-
- def test_unchanged(self):
- from Products.CMFSetup.catalog import exportCatalogTool
-
- site = self._initSite(0)
- context = DummyExportContext(site)
- exportCatalogTool(context)
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'catalog.xml')
- self._compareDOM(text, _EMPTY_EXPORT)
- self.assertEqual(content_type, 'text/xml')
-
- def test_normal(self):
- from Products.CMFSetup.catalog import exportCatalogTool
-
- site = self._initSite(2)
- context = DummyExportContext(site)
- exportCatalogTool(context)
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'catalog.xml')
- self._compareDOM(text, _NORMAL_EXPORT)
- self.assertEqual(content_type, 'text/xml')
-
-
-class Test_importCatalogTool(_CatalogToolSetup):
-
- def test_empty_purge(self):
- from Products.CMFSetup.catalog import importCatalogTool
-
- site = self._initSite(2)
- ctool = site.portal_catalog
-
- self.assertEqual(len(ctool.objectIds()), 1)
- self.assertEqual(len(ctool.indexes()), 1)
- self.assertEqual(len(ctool.schema()), 1)
-
- context = DummyImportContext(site, True)
- context._files['catalog.xml'] = _EMPTY_EXPORT
- importCatalogTool(context)
-
- self.assertEqual(len(ctool.objectIds()), 0)
- self.assertEqual(len(ctool.indexes()), 0)
- self.assertEqual(len(ctool.schema()), 0)
-
- def test_empty_update(self):
- from Products.CMFSetup.catalog import importCatalogTool
-
- site = self._initSite(2)
- ctool = site.portal_catalog
-
- self.assertEqual(len(ctool.objectIds()), 1)
- self.assertEqual(len(ctool.indexes()), 1)
- self.assertEqual(len(ctool.schema()), 1)
-
- context = DummyImportContext(site, False)
- context._files['catalog.xml'] = _EMPTY_EXPORT
- importCatalogTool(context)
-
- self.assertEqual(len(ctool.objectIds()), 1)
- self.assertEqual(len(ctool.indexes()), 1)
- self.assertEqual(len(ctool.schema()), 1)
-
- def test_normal_purge(self):
- from Products.CMFSetup.catalog import exportCatalogTool
- from Products.CMFSetup.catalog import importCatalogTool
-
- site = self._initSite(2)
- ctool = site.portal_catalog
-
- self.assertEqual(len(ctool.objectIds()), 1)
- self.assertEqual(len(ctool.indexes()), 1)
- self.assertEqual(len(ctool.schema()), 1)
-
- context = DummyImportContext(site, True)
- context._files['catalog.xml'] = _NORMAL_EXPORT
- importCatalogTool(context)
-
- self.assertEqual(len(ctool.objectIds()), 1)
- self.assertEqual(len(ctool.indexes()), 1)
- self.assertEqual(len(ctool.schema()), 1)
-
- # complete the roundtrip
- context = DummyExportContext(site)
- exportCatalogTool(context)
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'catalog.xml')
- self._compareDOM(text, _NORMAL_EXPORT)
- self.assertEqual(content_type, 'text/xml')
-
- def test_normal_update(self):
- from Products.CMFSetup.catalog import importCatalogTool
-
- site = self._initSite(2)
- ctool = site.portal_catalog
-
- self.assertEqual(len(ctool.objectIds()), 1)
- self.assertEqual(len(ctool.indexes()), 1)
- self.assertEqual(len(ctool.schema()), 1)
-
- context = DummyImportContext(site, False)
- context._files['catalog.xml'] = _UPDATE_IMPORT
- importCatalogTool(context)
-
- self.assertEqual(len(ctool.objectIds()), 1)
- self.assertEqual(len(ctool.indexes()), 2)
- self.assertEqual(len(ctool.schema()), 2)
-
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(Test_exportCatalogTool),
- unittest.makeSuite(Test_importCatalogTool),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
Deleted: CMF/trunk/CMFSetup/tests/test_contenttyperegistry.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_contenttyperegistry.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFSetup/tests/test_contenttyperegistry.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -1,203 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""ContentTypeRegistry setup handler unit tests.
-
-$Id$
-"""
-
-import unittest
-import Testing
-
-import Products
-from Products.Five import zcml
-
-from Products.CMFCore.tests.base.testcase import PlacelessSetup
-from Products.GenericSetup.tests.common import BaseRegistryTests
-from Products.GenericSetup.tests.common import DummyExportContext
-from Products.GenericSetup.tests.common import DummyImportContext
-
-_TEST_PREDICATES = (
- ('plain_text', 'major_minor', ('text', 'plain,javascript'), 'File'),
- ('stylesheets', 'extension', ('css,xsl,xslt',), 'Text File'),
- ('images', 'mimetype_regex', ('image/.*',), 'Image'),
- ('logfiles', 'name_regex', ('error_log-.*',), 'Log File'),
-)
-
-class _ContentTypeRegistrySetup(PlacelessSetup, BaseRegistryTests):
-
- MAJOR_MINOR_ID = _TEST_PREDICATES[0][0]
- MAJOR = _TEST_PREDICATES[0][2][0]
- MINOR = _TEST_PREDICATES[0][2][1]
- MAJOR_MINOR_TYPENAME = _TEST_PREDICATES[0][3]
- EXTENSION_ID = _TEST_PREDICATES[1][0]
- EXTENSIONS = _TEST_PREDICATES[1][2][0]
- EXTENSION_TYPENAME = _TEST_PREDICATES[1][3]
- MIMETYPE_REGEX_ID = _TEST_PREDICATES[2][0]
- MIMETYPE_REGEX = _TEST_PREDICATES[2][2][0]
- MIMETYPE_REGEX_TYPENAME = _TEST_PREDICATES[2][3]
- NAME_REGEX_ID = _TEST_PREDICATES[3][0]
- NAME_REGEX = _TEST_PREDICATES[3][2][0]
- NAME_REGEX_TYPENAME = _TEST_PREDICATES[3][3]
-
- _EMPTY_EXPORT = """\
-<?xml version="1.0"?>
-<object name="content_type_registry" meta_type="Content Type Registry"/>
-"""
-
- _WITH_POLICY_EXPORT = """\
-<?xml version="1.0"?>
-<object name="content_type_registry" meta_type="Content Type Registry">
- <predicate name="%s" content_type_name="%s"
- predicate_type="major_minor">
- <argument value="%s"/>
- <argument value="%s"/>
- </predicate>
- <predicate name="%s" content_type_name="%s"
- predicate_type="extension">
- <argument value="%s"/>
- </predicate>
- <predicate name="%s" content_type_name="%s"
- predicate_type="mimetype_regex">
- <argument value="%s"/>
- </predicate>
- <predicate name="%s" content_type_name="%s"
- predicate_type="name_regex">
- <argument value="%s"/>
- </predicate>
-</object>
-""" % (MAJOR_MINOR_ID,
- MAJOR_MINOR_TYPENAME,
- MAJOR,
- MINOR,
- EXTENSION_ID,
- EXTENSION_TYPENAME,
- EXTENSIONS,
- MIMETYPE_REGEX_ID,
- MIMETYPE_REGEX_TYPENAME,
- MIMETYPE_REGEX,
- NAME_REGEX_ID,
- NAME_REGEX_TYPENAME,
- NAME_REGEX,
- )
-
- def _initSite(self, mit_predikat=False):
- from OFS.Folder import Folder
- from Products.CMFCore.ContentTypeRegistry import ContentTypeRegistry
-
- self.root.site = Folder(id='site')
- site = self.root.site
- ctr = ContentTypeRegistry()
- site._setObject( ctr.getId(), ctr )
-
- if mit_predikat:
- for (predicate_id, predicate_type, edit_args, content_type_name
- ) in _TEST_PREDICATES:
- ctr.addPredicate(predicate_id, predicate_type)
- predicate = ctr.getPredicate(predicate_id)
- predicate.edit(*edit_args)
- ctr.assignTypeName(predicate_id, content_type_name)
-
- return site
-
- def setUp(self):
- PlacelessSetup.setUp(self)
- BaseRegistryTests.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
-
- def tearDown(self):
- BaseRegistryTests.tearDown(self)
- PlacelessSetup.tearDown(self)
-
-
-class Test_exportContentTypeRegistry(_ContentTypeRegistrySetup):
-
- def test_empty(self):
- from Products.CMFSetup.contenttyperegistry \
- import exportContentTypeRegistry
-
- site = self._initSite(mit_predikat=False)
- context = DummyExportContext(site)
- exportContentTypeRegistry(context)
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'contenttyperegistry.xml')
- self._compareDOM(text, self._EMPTY_EXPORT)
- self.assertEqual(content_type, 'text/xml')
-
- def test_with_policy(self):
- from Products.CMFSetup.contenttyperegistry \
- import exportContentTypeRegistry
-
- site = self._initSite(mit_predikat=True)
- context = DummyExportContext(site)
- exportContentTypeRegistry(context)
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'contenttyperegistry.xml')
- self._compareDOM(text, self._WITH_POLICY_EXPORT)
- self.assertEqual(content_type, 'text/xml')
-
-
-class Test_importContentTypeRegistry(_ContentTypeRegistrySetup):
-
- def test_normal(self):
- from Products.CMFSetup.contenttyperegistry \
- import importContentTypeRegistry
-
- site = self._initSite(mit_predikat=False)
- ctr = site.content_type_registry
- self.assertEqual(len(ctr.listPredicates()), 0)
-
- context = DummyImportContext(site)
- context._files['contenttyperegistry.xml'] = self._WITH_POLICY_EXPORT
- importContentTypeRegistry(context)
-
- self.assertEqual(len(ctr.listPredicates()), len(_TEST_PREDICATES))
-
- predicate_id, (predicate, content_type_name) = ctr.listPredicates()[0]
- self.assertEqual(predicate_id, self.MAJOR_MINOR_ID)
- self.assertEqual(predicate.PREDICATE_TYPE, 'major_minor')
- self.assertEqual(content_type_name, self.MAJOR_MINOR_TYPENAME)
- self.assertEqual(predicate.major, self.MAJOR.split(','))
- self.assertEqual(predicate.minor, self.MINOR.split(','))
-
- predicate_id, (predicate, content_type_name) = ctr.listPredicates()[1]
- self.assertEqual(predicate_id, self.EXTENSION_ID)
- self.assertEqual(predicate.PREDICATE_TYPE, 'extension')
- self.assertEqual(content_type_name, self.EXTENSION_TYPENAME)
- self.assertEqual(predicate.extensions, self.EXTENSIONS.split(','))
-
- predicate_id, (predicate, content_type_name) = ctr.listPredicates()[2]
- self.assertEqual(predicate_id, self.MIMETYPE_REGEX_ID)
- self.assertEqual(predicate.PREDICATE_TYPE, 'mimetype_regex')
- self.assertEqual(content_type_name, self.MIMETYPE_REGEX_TYPENAME)
- self.assertEqual(predicate.pattern.pattern, self.MIMETYPE_REGEX)
-
- predicate_id, (predicate, content_type_name) = ctr.listPredicates()[3]
- self.assertEqual(predicate_id, self.NAME_REGEX_ID)
- self.assertEqual(predicate.PREDICATE_TYPE, 'name_regex')
- self.assertEqual(content_type_name, self.NAME_REGEX_TYPENAME)
- self.assertEqual(predicate.pattern.pattern, self.NAME_REGEX)
-
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(Test_exportContentTypeRegistry),
- unittest.makeSuite(Test_importContentTypeRegistry),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
Deleted: CMF/trunk/CMFSetup/tests/test_cookieauth.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_cookieauth.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFSetup/tests/test_cookieauth.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -1,157 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Cookie crumbler setup handler unit tests.
-
-$Id$
-"""
-
-import unittest
-import Testing
-
-import Products
-from OFS.Folder import Folder
-from Products.Five import zcml
-
-from Products.CMFCore.CookieCrumbler import CookieCrumbler
-from Products.CMFCore.tests.base.testcase import PlacelessSetup
-from Products.GenericSetup.tests.common import BaseRegistryTests
-from Products.GenericSetup.tests.common import DummyExportContext
-from Products.GenericSetup.tests.common import DummyImportContext
-
-
-class _CookieCrumblerSetup(PlacelessSetup, BaseRegistryTests):
-
- def _initSite(self, use_changed=False):
- self.root.site = Folder(id='site')
- site = self.root.site
- cc = site.cookie_authentication = CookieCrumbler('foo_cookiecrumbler')
-
- if use_changed:
- cc.auth_cookie = 'value1'
- cc.cache_header_value = 'value2'
- cc.name_cookie = 'value3'
- cc.log_username = 0
- cc.persist_cookie = 'value4'
- cc.pw_cookie = 'value5'
- cc.local_cookie_path = 1
- cc.auto_login_page = 'value6'
- cc.unauth_page = 'value7'
- cc.logout_page = 'value8'
-
- return site
-
- def setUp(self):
- PlacelessSetup.setUp(self)
- BaseRegistryTests.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
-
- def tearDown(self):
- BaseRegistryTests.tearDown(self)
- PlacelessSetup.tearDown(self)
-
-
-_DEFAULT_EXPORT = """\
-<?xml version="1.0"?>
-<object name="foo_cookiecrumbler" meta_type="Cookie Crumbler">
- <property name="auth_cookie">__ac</property>
- <property name="name_cookie">__ac_name</property>
- <property name="pw_cookie">__ac_password</property>
- <property name="persist_cookie">__ac_persistent</property>
- <property name="auto_login_page">login_form</property>
- <property name="logout_page">logged_out</property>
- <property name="unauth_page"></property>
- <property name="local_cookie_path">False</property>
- <property name="cache_header_value">private</property>
- <property name="log_username">True</property>
-</object>
-"""
-
-_CHANGED_EXPORT = """\
-<?xml version="1.0"?>
-<object name="foo_cookiecrumbler" meta_type="Cookie Crumbler">
- <property name="auth_cookie">value1</property>
- <property name="name_cookie">value3</property>
- <property name="pw_cookie">value5</property>
- <property name="persist_cookie">value4</property>
- <property name="auto_login_page">value6</property>
- <property name="logout_page">value8</property>
- <property name="unauth_page">value7</property>
- <property name="local_cookie_path">True</property>
- <property name="cache_header_value">value2</property>
- <property name="log_username">False</property>
-</object>
-"""
-
-
-class Test_exportCookieCrumbler(_CookieCrumblerSetup):
-
- def test_unchanged(self):
- from Products.CMFSetup.cookieauth import exportCookieCrumbler
-
- site = self._initSite(use_changed=False)
- context = DummyExportContext(site)
- exportCookieCrumbler(context)
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'cookieauth.xml')
- self._compareDOM(text, _DEFAULT_EXPORT)
- self.assertEqual(content_type, 'text/xml')
-
- def test_changed(self):
- from Products.CMFSetup.cookieauth import exportCookieCrumbler
-
- site = self._initSite(use_changed=True)
- context = DummyExportContext(site)
- exportCookieCrumbler(context)
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'cookieauth.xml')
- self._compareDOM(text, _CHANGED_EXPORT)
- self.assertEqual(content_type, 'text/xml')
-
-
-class Test_importCookieCrumbler(_CookieCrumblerSetup):
-
- def test_normal(self):
- from Products.CMFSetup.cookieauth import importCookieCrumbler
-
- site = self._initSite()
- cc = site.cookie_authentication
-
- context = DummyImportContext(site)
- context._files['cookieauth.xml'] = _CHANGED_EXPORT
- importCookieCrumbler(context)
-
- self.assertEqual( cc.auth_cookie, 'value1' )
- self.assertEqual( cc.cache_header_value, 'value2' )
- self.assertEqual( cc.name_cookie, 'value3' )
- self.assertEqual( cc.log_username, 0 )
- self.assertEqual( cc.persist_cookie, 'value4' )
- self.assertEqual( cc.pw_cookie, 'value5' )
- self.assertEqual( cc.local_cookie_path, 1 )
- self.assertEqual( cc.auto_login_page, 'value6' )
- self.assertEqual( cc.unauth_page, 'value7' )
- self.assertEqual( cc.logout_page, 'value8' )
-
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(Test_exportCookieCrumbler),
- unittest.makeSuite(Test_importCookieCrumbler),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
Deleted: CMF/trunk/CMFSetup/tests/test_mailhost.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_mailhost.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFSetup/tests/test_mailhost.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -1,125 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Mailhost setup handler unit tests.
-
-$Id$
-"""
-
-import unittest
-import Testing
-
-import Products
-from OFS.Folder import Folder
-from Products.Five import zcml
-from Products.MailHost.MailHost import MailHost
-
-from Products.CMFCore.tests.base.testcase import PlacelessSetup
-from Products.GenericSetup.tests.common import BaseRegistryTests
-from Products.GenericSetup.tests.common import DummyExportContext
-from Products.GenericSetup.tests.common import DummyImportContext
-
-
-class _MailHostSetup(PlacelessSetup, BaseRegistryTests):
-
- def _initSite(self, use_changed=False):
- self.root.site = Folder(id='site')
- site = self.root.site
- mh = site.MailHost = MailHost('MailHost')
-
- if use_changed:
- mh.smtp_port='1'
- mh.smtp_pwd="value1"
- mh.smtp_host="value2"
- mh.smtp_uid="value3"
-
- return site
-
- def setUp(self):
- PlacelessSetup.setUp(self)
- BaseRegistryTests.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.GenericSetup.MailHost)
-
- def tearDown(self):
- BaseRegistryTests.tearDown(self)
- PlacelessSetup.tearDown(self)
-
-
-_DEFAULT_EXPORT = """\
-<?xml version="1.0"?>
-<object name="MailHost" meta_type="Mail Host" smtp_host="localhost"
- smtp_port="25" smtp_pwd="" smtp_uid=""/>
-"""
-
-_CHANGED_EXPORT = """\
-<?xml version="1.0"?>
-<object name="MailHost" meta_type="Mail Host" smtp_host="value2"
- smtp_port="1" smtp_pwd="value1" smtp_uid="value3"/>
-"""
-
-
-class Test_exportMailHost(_MailHostSetup):
-
- def test_unchanged(self):
- from Products.CMFSetup.mailhost import exportMailHost
-
- site = self._initSite(use_changed=False)
- context = DummyExportContext(site)
- exportMailHost(context)
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'mailhost.xml')
- self._compareDOM(text, _DEFAULT_EXPORT)
- self.assertEqual(content_type, 'text/xml')
-
- def test_changed(self):
- from Products.CMFSetup.mailhost import exportMailHost
-
- site = self._initSite(use_changed=True)
- context = DummyExportContext(site)
- exportMailHost(context)
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'mailhost.xml')
- self._compareDOM(text, _CHANGED_EXPORT)
- self.assertEqual(content_type, 'text/xml')
-
-
-class Test_importMailHost(_MailHostSetup):
-
- def test_normal(self):
- from Products.CMFSetup.mailhost import importMailHost
-
- site = self._initSite()
- mh = site.MailHost
-
- context = DummyImportContext(site)
- context._files['mailhost.xml'] = _CHANGED_EXPORT
- importMailHost(context)
-
- self.assertEqual( mh.smtp_pwd, 'value1' )
- self.assertEqual( mh.smtp_host, 'value2' )
- self.assertEqual( mh.smtp_uid, 'value3' )
- self.assertEqual( mh.smtp_port, 1 )
-
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(Test_exportMailHost),
- unittest.makeSuite(Test_importMailHost),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
Deleted: CMF/trunk/CMFSetup/tests/test_properties.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_properties.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/CMFSetup/tests/test_properties.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -1,196 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" Site properties export / import unit tests.
-
-$Id$
-"""
-
-import unittest
-import Testing
-
-import Products
-from Products.Five import zcml
-from Products.CMFCore.PortalObject import PortalObjectBase
-from Products.CMFCore.tests.base.testcase import PlacelessSetup
-
-from Products.GenericSetup.tests.common import BaseRegistryTests
-from Products.GenericSetup.tests.common import DummyExportContext
-from Products.GenericSetup.tests.common import DummyImportContext
-
-
-_EMPTY_EXPORT = """\
-<?xml version="1.0" ?>
-<site>
- <property name="title"/>
-</site>
-"""
-
-_NORMAL_EXPORT = """\
-<?xml version="1.0" ?>
-<site>
- <property name="title"/>
- <property name="foo" type="string">Foo</property>
- <property name="bar" type="tokens">
- <element value="Bar"/>
- </property>
- <property name="moo" type="tokens">
- <element value="Moo"/>
- </property>
-</site>
-"""
-
-
-class _SitePropertiesSetup(PlacelessSetup, BaseRegistryTests):
-
- def _initSite(self, foo=2, bar=2):
-
- self.root.site = PortalObjectBase('foo_site')
- site = self.root.site
-
- if foo > 0:
- site._setProperty('foo', '', 'string')
- if foo > 1:
- site._updateProperty('foo', 'Foo')
-
- if bar > 0:
- site._setProperty( 'bar', (), 'tokens' )
- site._setProperty( 'moo', (), 'tokens' )
- if bar > 1:
- site._updateProperty( 'bar', ('Bar',) )
- site.moo = ['Moo']
-
- return site
-
- def setUp(self):
- PlacelessSetup.setUp(self)
- BaseRegistryTests.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
-
- def tearDown(self):
- BaseRegistryTests.tearDown(self)
- PlacelessSetup.tearDown(self)
-
-
-class Test_exportSiteProperties(_SitePropertiesSetup):
-
- def test_empty(self):
- from Products.CMFSetup.properties import exportSiteProperties
-
- site = self._initSite(0, 0)
- context = DummyExportContext(site)
- exportSiteProperties(context)
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'properties.xml')
- self._compareDOM(text, _EMPTY_EXPORT)
- self.assertEqual(content_type, 'text/xml')
-
- def test_normal(self):
- from Products.CMFSetup.properties import exportSiteProperties
-
- site = self._initSite()
- context = DummyExportContext( site )
- exportSiteProperties(context)
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'properties.xml')
- self._compareDOM(text, _NORMAL_EXPORT)
- self.assertEqual(content_type, 'text/xml')
-
-
-class Test_importSiteProperties(_SitePropertiesSetup):
-
- def test_empty_default_purge(self):
- from Products.CMFSetup.properties import importSiteProperties
-
- site = self._initSite()
-
- self.assertEqual( len( site.propertyIds() ), 4 )
- self.failUnless( 'foo' in site.propertyIds() )
- self.assertEqual( site.getProperty('foo'), 'Foo' )
- self.failUnless( 'bar' in site.propertyIds() )
- self.assertEqual( site.getProperty('bar'), ('Bar',) )
-
- context = DummyImportContext(site)
- context._files['properties.xml'] = _EMPTY_EXPORT
- importSiteProperties(context)
-
- self.assertEqual( len( site.propertyIds() ), 1 )
-
- def test_empty_explicit_purge(self):
- from Products.CMFSetup.properties import importSiteProperties
-
- site = self._initSite()
-
- self.assertEqual( len( site.propertyIds() ), 4 )
- self.failUnless( 'foo' in site.propertyIds() )
- self.assertEqual( site.getProperty('foo'), 'Foo' )
- self.failUnless( 'bar' in site.propertyIds() )
- self.assertEqual( site.getProperty('bar'), ('Bar',) )
-
- context = DummyImportContext(site, True)
- context._files['properties.xml'] = _EMPTY_EXPORT
- importSiteProperties(context)
-
- self.assertEqual( len( site.propertyIds() ), 1 )
-
- def test_empty_skip_purge(self):
- from Products.CMFSetup.properties import importSiteProperties
-
- site = self._initSite()
-
- self.assertEqual( len( site.propertyIds() ), 4 )
- self.failUnless( 'foo' in site.propertyIds() )
- self.assertEqual( site.getProperty('foo'), 'Foo' )
- self.failUnless( 'bar' in site.propertyIds() )
- self.assertEqual( site.getProperty('bar'), ('Bar',) )
-
- context = DummyImportContext(site, False)
- context._files['properties.xml'] = _EMPTY_EXPORT
- importSiteProperties(context)
-
- self.assertEqual( len( site.propertyIds() ), 4 )
- self.failUnless( 'foo' in site.propertyIds() )
- self.assertEqual( site.getProperty('foo'), 'Foo' )
- self.failUnless( 'bar' in site.propertyIds() )
- self.assertEqual( site.getProperty('bar'), ('Bar',) )
-
- def test_normal(self):
- from Products.CMFSetup.properties import importSiteProperties
-
- site = self._initSite(0,0)
-
- self.assertEqual( len( site.propertyIds() ), 1 )
-
- context = DummyImportContext(site)
- context._files['properties.xml'] = _NORMAL_EXPORT
- importSiteProperties(context)
-
- self.assertEqual( len( site.propertyIds() ), 4 )
- self.failUnless( 'foo' in site.propertyIds() )
- self.assertEqual( site.getProperty('foo'), 'Foo' )
- self.failUnless( 'bar' in site.propertyIds() )
- self.assertEqual( site.getProperty('bar'), ('Bar',) )
-
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(Test_exportSiteProperties),
- unittest.makeSuite(Test_importSiteProperties),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
Modified: CMF/trunk/GenericSetup/MailHost/configure.zcml
===================================================================
--- CMF/trunk/GenericSetup/MailHost/configure.zcml 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/GenericSetup/MailHost/configure.zcml 2005-11-29 19:44:07 UTC (rev 40413)
@@ -3,15 +3,10 @@
>
<adapter
- factory=".exportimport.MailHostNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeExporter"
- for="Products.MailHost.interfaces.IMailHost"
+ factory=".exportimport.MailHostXMLAdapter"
+ provides="Products.GenericSetup.interfaces.IBody"
+ for="Products.MailHost.interfaces.IMailHost
+ Products.GenericSetup.interfaces.ISetupContext"
/>
- <adapter
- factory=".exportimport.MailHostNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeImporter"
- for="Products.MailHost.interfaces.IMailHost"
- />
-
</configure>
Modified: CMF/trunk/GenericSetup/MailHost/exportimport.py
===================================================================
--- CMF/trunk/GenericSetup/MailHost/exportimport.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/GenericSetup/MailHost/exportimport.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -16,18 +16,20 @@
"""
from Products.GenericSetup.interfaces import PURGE
-from Products.GenericSetup.utils import NodeAdapterBase
+from Products.GenericSetup.utils import XMLAdapterBase
from Products.MailHost.interfaces import IMailHost
-class MailHostNodeAdapter(NodeAdapterBase):
+class MailHostXMLAdapter(XMLAdapterBase):
- """Node im- and exporter for MailHost.
+ """XML im- and exporter for MailHost.
"""
__used_for__ = IMailHost
+ _LOGGER_ID = 'mailhost'
+
def exportNode(self, doc):
"""Export the object as a DOM node.
"""
@@ -37,6 +39,8 @@
node.setAttribute('smtp_port', str(self.context.smtp_port))
node.setAttribute('smtp_uid', self.context.smtp_uid)
node.setAttribute('smtp_pwd', self.context.smtp_pwd)
+
+ self._logger.info('Mailhost exported.')
return node
def importNode(self, node, mode=PURGE):
@@ -46,3 +50,5 @@
self.context.smtp_port = int(node.getAttribute('smtp_port'))
self.context.smtp_uid = node.getAttribute('smtp_uid').encode('utf-8')
self.context.smtp_pwd = node.getAttribute('smtp_pwd').encode('utf-8')
+
+ self._logger.info('Mailhost imported.')
Modified: CMF/trunk/GenericSetup/MailHost/tests/test_exportimport.py
===================================================================
--- CMF/trunk/GenericSetup/MailHost/tests/test_exportimport.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/GenericSetup/MailHost/tests/test_exportimport.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -18,22 +18,24 @@
import unittest
import Testing
-from Products.GenericSetup.testing import NodeAdapterTestCase
-from Products.GenericSetup.testing import PlacelessSetup
+from Products.Five import zcml
-_MAILHOST_XML = """\
+from Products.GenericSetup.testing import BodyAdapterTestCase
+
+_MAILHOST_BODY = """\
+<?xml version="1.0"?>
<object name="foo_mailhost" meta_type="Mail Host" smtp_host="localhost"
smtp_port="25" smtp_pwd="" smtp_uid=""/>
"""
-class MailHostNodeAdapterTests(PlacelessSetup, NodeAdapterTestCase):
+class MailHostXMLAdapterTests(BodyAdapterTestCase):
def _getTargetClass(self):
from Products.GenericSetup.MailHost.exportimport \
- import MailHostNodeAdapter
+ import MailHostXMLAdapter
- return MailHostNodeAdapter
+ return MailHostXMLAdapter
def _verifyImport(self, obj):
self.assertEqual(type(obj.smtp_host), str)
@@ -46,22 +48,19 @@
self.assertEqual(obj.smtp_uid, '')
def setUp(self):
- import Products.Five
- from Products.Five import zcml
import Products.GenericSetup.MailHost
from Products.MailHost.MailHost import MailHost
- PlacelessSetup.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
+ BodyAdapterTestCase.setUp(self)
zcml.load_config('configure.zcml', Products.GenericSetup.MailHost)
self._obj = MailHost('foo_mailhost')
- self._XML = _MAILHOST_XML
+ self._BODY = _MAILHOST_BODY
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(MailHostNodeAdapterTests),
+ unittest.makeSuite(MailHostXMLAdapterTests),
))
if __name__ == '__main__':
Modified: CMF/trunk/GenericSetup/OFSP/exportimport.py
===================================================================
--- CMF/trunk/GenericSetup/OFSP/exportimport.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/GenericSetup/OFSP/exportimport.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -31,6 +31,8 @@
__used_for__ = IFolder
+ _LOGGER_ID = 'ofs'
+
def exportNode(self, doc):
"""Export the object as a DOM node.
"""
@@ -38,6 +40,8 @@
node = self._getObjectNode('object')
node.appendChild(self._extractProperties())
node.appendChild(self._extractObjects())
+
+ self._logger.info('Folder exported.')
return node
def importNode(self, node, mode=PURGE):
@@ -50,6 +54,8 @@
self._initProperties(node, mode)
self._initObjects(node, mode)
+ self._logger.info('Folder imported.')
+
def _exportBody(self):
"""Export the object as a file body.
"""
Modified: CMF/trunk/GenericSetup/ZCatalog/configure.zcml
===================================================================
--- CMF/trunk/GenericSetup/ZCatalog/configure.zcml 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/GenericSetup/ZCatalog/configure.zcml 2005-11-29 19:44:07 UTC (rev 40413)
@@ -3,15 +3,10 @@
>
<adapter
- factory=".exportimport.ZCatalogNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeExporter"
- for="Products.ZCatalog.interfaces.IZCatalog"
+ factory=".exportimport.ZCatalogXMLAdapter"
+ provides="Products.GenericSetup.interfaces.IBody"
+ for="Products.ZCatalog.interfaces.IZCatalog
+ Products.GenericSetup.interfaces.ISetupContext"
/>
- <adapter
- factory=".exportimport.ZCatalogNodeAdapter"
- provides="Products.GenericSetup.interfaces.INodeImporter"
- for="Products.ZCatalog.interfaces.IZCatalog"
- />
-
</configure>
Modified: CMF/trunk/GenericSetup/ZCatalog/exportimport.py
===================================================================
--- CMF/trunk/GenericSetup/ZCatalog/exportimport.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/GenericSetup/ZCatalog/exportimport.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -18,9 +18,9 @@
from Products.GenericSetup.interfaces import INodeExporter
from Products.GenericSetup.interfaces import INodeImporter
from Products.GenericSetup.interfaces import PURGE
-from Products.GenericSetup.utils import NodeAdapterBase
from Products.GenericSetup.utils import ObjectManagerHelpers
from Products.GenericSetup.utils import PropertyManagerHelpers
+from Products.GenericSetup.utils import XMLAdapterBase
from Products.ZCatalog.interfaces import IZCatalog
@@ -30,14 +30,16 @@
pass
-class ZCatalogNodeAdapter(NodeAdapterBase, ObjectManagerHelpers,
- PropertyManagerHelpers):
+class ZCatalogXMLAdapter(XMLAdapterBase, ObjectManagerHelpers,
+ PropertyManagerHelpers):
- """Node im- and exporter for ZCatalog.
+ """XML im- and exporter for ZCatalog.
"""
__used_for__ = IZCatalog
+ _LOGGER_ID = 'catalog'
+
def exportNode(self, doc):
"""Export the object as a DOM node.
"""
@@ -47,6 +49,8 @@
node.appendChild(self._extractObjects())
node.appendChild(self._extractIndexes())
node.appendChild(self._extractColumns())
+
+ self._logger.info('Catalog exported.')
return node
def importNode(self, node, mode=PURGE):
@@ -63,6 +67,8 @@
self._initIndexes(node, mode)
self._initColumns(node, mode)
+ self._logger.info('Catalog imported.')
+
def _extractIndexes(self):
fragment = self._doc.createDocumentFragment()
indexes = self.context.getIndexObjects()[:]
Modified: CMF/trunk/GenericSetup/ZCatalog/tests/test_exportimport.py
===================================================================
--- CMF/trunk/GenericSetup/ZCatalog/tests/test_exportimport.py 2005-11-29 16:24:03 UTC (rev 40412)
+++ CMF/trunk/GenericSetup/ZCatalog/tests/test_exportimport.py 2005-11-29 19:44:07 UTC (rev 40413)
@@ -20,20 +20,21 @@
import Zope2
Zope2.startup()
-import Products
from Products.Five import zcml
-from Products.GenericSetup.interfaces import INodeExporter
-from Products.GenericSetup.testing import NodeAdapterTestCase
-from Products.GenericSetup.testing import PlacelessSetup
-from Products.GenericSetup.utils import PrettyDocument
+from zope.app import zapi
+from Products.GenericSetup.interfaces import IBody
+from Products.GenericSetup.testing import BodyAdapterTestCase
+from Products.GenericSetup.tests.common import DummyExportContext
+
class _extra:
pass
-_CATALOG_XML = """\
+_CATALOG_BODY = """\
+<?xml version="1.0"?>
<object name="foo_catalog" meta_type="ZCatalog">
<property name="title"></property>
<object name="foo_plexicon" meta_type="ZCTextIndex Lexicon">
@@ -76,13 +77,13 @@
"""
-class ZCatalogNodeAdapterTests(PlacelessSetup, NodeAdapterTestCase):
+class ZCatalogXMLAdapterTests(BodyAdapterTestCase):
def _getTargetClass(self):
from Products.GenericSetup.ZCatalog.exportimport \
- import ZCatalogNodeAdapter
+ import ZCatalogXMLAdapter
- return ZCatalogNodeAdapter
+ return ZCatalogXMLAdapter
def _populate(self, obj):
from Products.ZCTextIndex.Lexicon import CaseNormalizer
@@ -131,28 +132,29 @@
obj.addIndex('foo_text', 'TextIndex')
def setUp(self):
+ import Products.GenericSetup
from Products.ZCatalog.ZCatalog import ZCatalog
- PlacelessSetup.setUp(self)
- zcml.load_config('meta.zcml', Products.Five)
+ BodyAdapterTestCase.setUp(self)
zcml.load_config('configure.zcml',
Products.GenericSetup.PluginIndexes)
zcml.load_config('configure.zcml', Products.GenericSetup.ZCatalog)
zcml.load_config('configure.zcml', Products.GenericSetup.ZCTextIndex)
self._obj = ZCatalog('foo_catalog')
- self._XML = _CATALOG_XML % ('', '')
+ self._BODY = _CATALOG_BODY % ('', '')
- def test_exportNode_special(self):
+ def test_body_get_special(self):
self._populate_special(self._obj)
- node = INodeExporter(self._obj).exportNode(PrettyDocument())
- self.assertEqual(node.toprettyxml(' '),
- _CATALOG_XML % (_VOCABULARY_XML, _TEXT_XML))
+ context = DummyExportContext(None)
+ exporter = zapi.getMultiAdapter((self._obj, context), IBody)
+ self.assertEqual(exporter.body,
+ _CATALOG_BODY % (_VOCABULARY_XML, _TEXT_XML))
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(ZCatalogNodeAdapterTests),
+ unittest.makeSuite(ZCatalogXMLAdapterTests),
))
if __name__ == '__main__':
More information about the CMF-checkins
mailing list