[CMF-checkins] SVN: CMF/trunk/CMF - converted caching policy
manager and content type registry setup handlers to new style
Yvo Schubbe
y.2005- at wcm-solutions.de
Sun Nov 13 14:55:09 EST 2005
Log message for revision 40087:
- converted caching policy manager and content type registry setup handlers to new style
- updated CMFDefault default profile
Changed:
A CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py
U CMF/trunk/CMFCore/exportimport/configure.zcml
A CMF/trunk/CMFCore/exportimport/contenttyperegistry.py
A CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py
A CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py
U CMF/trunk/CMFDefault/profiles/default/cachingpolicymgr.xml
U CMF/trunk/CMFDefault/profiles/default/contenttyperegistry.xml
U CMF/trunk/CMFSetup/cachingpolicymgr.py
U CMF/trunk/CMFSetup/contenttyperegistry.py
U CMF/trunk/CMFSetup/tests/test_cachingpolicymgr.py
U CMF/trunk/CMFSetup/tests/test_contenttyperegistry.py
D CMF/trunk/CMFSetup/xml/cpmExport.xml
D CMF/trunk/CMFSetup/xml/ctrExport.xml
-=-
Added: CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py 2005-11-13 19:09:36 UTC (rev 40086)
+++ CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py 2005-11-13 19:55:09 UTC (rev 40087)
@@ -0,0 +1,157 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Caching policy manager node adapters.
+
+$Id$
+"""
+
+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.CMFCore.interfaces import ICachingPolicy
+from Products.CMFCore.interfaces import ICachingPolicyManager
+
+
+class CachingPolicyNodeAdapter(NodeAdapterBase):
+
+ """Node im- and exporter for CachingPolicy.
+ """
+
+ __used_for__ = ICachingPolicy
+
+ def exportNode(self, doc):
+ """Export the object as a DOM node.
+ """
+ self._doc = doc
+ obj = self.context
+ node = self._doc.createElement('caching-policy')
+ node.setAttribute('name', obj.getPolicyId())
+ node.setAttribute('predicate', obj.getPredicate())
+ node.setAttribute('mtime_func', obj.getMTimeFunc())
+ node.setAttribute('max_age_secs', str(obj.getMaxAgeSecs()))
+ node.setAttribute('no_cache', str(bool(obj.getNoCache())))
+ node.setAttribute('no_store', str(bool(obj.getNoStore())))
+ node.setAttribute('must_revalidate',
+ str(bool(obj.getMustRevalidate())))
+ node.setAttribute('vary', obj.getVary())
+ node.setAttribute('etag_func', obj.getETagFunc())
+ s_max_age_secs = obj.getSMaxAgeSecs()
+ if s_max_age_secs is not None:
+ node.setAttribute('s_max_age_secs', str(s_max_age_secs))
+ node.setAttribute('proxy_revalidate',
+ str(bool(obj.getProxyRevalidate())))
+ node.setAttribute('public', str(bool(obj.getPublic())))
+ node.setAttribute('private', str(bool(obj.getPrivate())))
+ node.setAttribute('no_transform', str(bool(obj.getNoTransform())))
+ node.setAttribute('enable_304s', str(bool(obj.getEnable304s())))
+ node.setAttribute('last_modified', str(bool(obj.getLastModified())))
+ pre_check = obj.getPreCheck()
+ if pre_check is not None:
+ node.setAttribute('pre_check', str(pre_check))
+ post_check = obj.getPostCheck()
+ if post_check is not None:
+ node.setAttribute('post_check', str(post_check))
+ return node
+
+ def importNode(self, node, mode=PURGE):
+ """Import the object from the DOM node.
+ """
+ info = {}
+ policy_id = node.getAttribute('name')
+ if not policy_id:
+ # BBB: for CMF 1.5 profiles
+ policy_id = node.getAttribute('policy_id')
+ info['policy_id'] = str(policy_id)
+ info['predicate'] = str(node.getAttribute('predicate'))
+ info['mtime_func'] = str(node.getAttribute('mtime_func'))
+ info['max_age_secs'] = int(node.getAttribute('max_age_secs'))
+ no_cache = node.getAttribute('no_cache')
+ info['no_cache'] = self._convertToBoolean(no_cache)
+ no_store = node.getAttribute('no_store')
+ info['no_store'] = self._convertToBoolean(no_store)
+ must_revalidate = node.getAttribute('must_revalidate')
+ info['must_revalidate'] = self._convertToBoolean(must_revalidate)
+ info['vary'] = str(node.getAttribute('vary'))
+ info['etag_func'] = str(node.getAttribute('etag_func'))
+ s_max_age_secs = node.getAttribute('s_max_age_secs')
+ if s_max_age_secs != '':
+ info['s_max_age_secs'] = int(s_max_age_secs)
+ proxy_revalidate = node.getAttribute('proxy_revalidate')
+ info['proxy_revalidate'] = self._convertToBoolean(proxy_revalidate)
+ info['public'] = self._convertToBoolean(node.getAttribute('public'))
+ info['private'] = self._convertToBoolean(node.getAttribute('private'))
+ no_transform = node.getAttribute('no_transform')
+ info['no_transform'] = self._convertToBoolean(no_transform)
+ enable_304s = node.getAttribute('enable_304s')
+ info['enable_304s'] = self._convertToBoolean(enable_304s)
+ last_modified = node.getAttribute('last_modified')
+ info['last_modified'] = self._convertToBoolean(last_modified)
+ pre_check = node.getAttribute('pre_check')
+ if pre_check != '':
+ info['pre_check'] = int(pre_check)
+ post_check = node.getAttribute('post_check')
+ if post_check != '':
+ info['post_check'] = int(post_check)
+ self.context.__init__(**info)
+
+
+class CachingPolicyManagerNodeAdapter(NodeAdapterBase):
+
+ """Node im- and exporter for CachingPolicyManager.
+ """
+
+ __used_for__ = ICachingPolicyManager
+
+ def exportNode(self, doc):
+ """Export the object as a DOM node.
+ """
+ self._doc = doc
+ node = self._getObjectNode('object')
+ node.appendChild(self._extractCachingPolicies())
+ return node
+
+ def importNode(self, node, mode=PURGE):
+ """Import the object from the DOM node.
+ """
+ if mode == PURGE:
+ self._purgeCachingPolicies()
+
+ self._initCachingPolicies(node, mode)
+
+ def _extractCachingPolicies(self):
+ fragment = self._doc.createDocumentFragment()
+ for policy_id, policy in self.context.listPolicies():
+ exporter = INodeExporter(policy, None)
+ if exporter is None:
+ continue
+ fragment.appendChild(exporter.exportNode(self._doc))
+ return fragment
+
+ def _purgeCachingPolicies(self):
+ self.context.__init__()
+
+ def _initCachingPolicies(self, node, mode):
+ for child in node.childNodes:
+ if child.nodeName != 'caching-policy':
+ continue
+ parent = self.context
+
+ policy_id = str(child.getAttribute('name'))
+ if policy_id not in parent._policy_ids:
+ parent.addPolicy(policy_id, 'python:1', 'object/modified',
+ 0, 0, 0, 0, '', '')
+
+ policy = self.context._policies[policy_id]
+ INodeImporter(policy).importNode(child, mode)
Property changes on: CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: CMF/trunk/CMFCore/exportimport/configure.zcml
===================================================================
--- CMF/trunk/CMFCore/exportimport/configure.zcml 2005-11-13 19:09:36 UTC (rev 40086)
+++ CMF/trunk/CMFCore/exportimport/configure.zcml 2005-11-13 19:55:09 UTC (rev 40087)
@@ -41,6 +41,30 @@
/>
<adapter
+ factory=".cachingpolicymgr.CachingPolicyNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeExporter"
+ for="Products.CMFCore.interfaces.ICachingPolicy"
+ />
+
+ <adapter
+ factory=".cachingpolicymgr.CachingPolicyNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeImporter"
+ for="Products.CMFCore.interfaces.ICachingPolicy"
+ />
+
+ <adapter
+ factory=".cachingpolicymgr.CachingPolicyManagerNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeExporter"
+ for="Products.CMFCore.interfaces.ICachingPolicyManager"
+ />
+
+ <adapter
+ factory=".cachingpolicymgr.CachingPolicyManagerNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeImporter"
+ for="Products.CMFCore.interfaces.ICachingPolicyManager"
+ />
+
+ <adapter
factory=".content.StructureFolderWalkingAdapter"
provides="Products.CMFCore.interfaces.IFilesystemExporter"
for="Products.CMFCore.interfaces.IFolderish"
@@ -89,6 +113,18 @@
/>
<adapter
+ factory=".contenttyperegistry.ContentTypeRegistryNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeExporter"
+ for="Products.CMFCore.interfaces.IContentTypeRegistry"
+ />
+
+ <adapter
+ factory=".contenttyperegistry.ContentTypeRegistryNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeImporter"
+ for="Products.CMFCore.interfaces.IContentTypeRegistry"
+ />
+
+ <adapter
factory=".cookieauth.CookieCrumblerNodeAdapter"
provides="Products.GenericSetup.interfaces.INodeExporter"
for="Products.CMFCore.interfaces.ICookieCrumbler"
Added: CMF/trunk/CMFCore/exportimport/contenttyperegistry.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/contenttyperegistry.py 2005-11-13 19:09:36 UTC (rev 40086)
+++ CMF/trunk/CMFCore/exportimport/contenttyperegistry.py 2005-11-13 19:55:09 UTC (rev 40087)
@@ -0,0 +1,99 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Content type registry node adapters.
+
+$Id$
+"""
+
+from Products.GenericSetup.interfaces import PURGE
+from Products.GenericSetup.utils import NodeAdapterBase
+
+from Products.CMFCore.interfaces import IContentTypeRegistry
+
+
+class ContentTypeRegistryNodeAdapter(NodeAdapterBase):
+
+ """Node im- and exporter for ContentTypeRegistry.
+ """
+
+ __used_for__ = IContentTypeRegistry
+
+ def exportNode(self, doc):
+ """Export the object as a DOM node.
+ """
+ self._doc = doc
+ node = self._getObjectNode('object')
+ node.appendChild(self._extractPredicates())
+ return node
+
+ def importNode(self, node, mode=PURGE):
+ """Import the object from the DOM node.
+ """
+ if mode == PURGE:
+ self._purgePredicates()
+
+ self._initPredicates(node, mode)
+
+ def _extractPredicates(self):
+ fragment = self._doc.createDocumentFragment()
+ for predicate_id, info in self.context.listPredicates():
+ child = self._doc.createElement('predicate')
+ child.setAttribute('name', predicate_id)
+ child.setAttribute('predicate_type', info[0].PREDICATE_TYPE)
+ child.setAttribute('content_type_name', info[1])
+ for argument in self._crackArgs(info[0]):
+ sub = self._doc.createElement('argument')
+ sub.setAttribute('value', argument)
+ child.appendChild(sub)
+ fragment.appendChild(child)
+ return fragment
+
+ def _purgePredicates(self):
+ self.context.__init__()
+
+ def _initPredicates(self, node, mode):
+ for child in node.childNodes:
+ if child.nodeName != 'predicate':
+ continue
+ parent = self.context
+
+ predicate_id = str(child.getAttribute('name'))
+ if not predicate_id:
+ # BBB: for CMF 1.5 profiles
+ predicate_id = str(child.getAttribute('predicate_id'))
+ predicate_type = str(child.getAttribute('predicate_type'))
+ content_type_name = str(child.getAttribute('content_type_name'))
+ if predicate_id not in parent.predicate_ids:
+ parent.addPredicate(predicate_id, predicate_type)
+
+ arguments = []
+ for sub in child.childNodes:
+ if sub.nodeName != 'argument':
+ continue
+ arguments.append(str(sub.getAttribute('value')))
+ parent.getPredicate(predicate_id).edit(*arguments)
+ parent.assignTypeName(predicate_id, content_type_name)
+
+ _KNOWN_PREDICATE_TYPES = {
+ 'major_minor': lambda x: (','.join(x.major or ()),
+ ','.join(x.minor or ())),
+ 'extension': lambda x: (','.join(x.extensions or ()),),
+ 'mimetype_regex': lambda x: (x.pattern and x.pattern.pattern or '',),
+ 'name_regex': lambda x: (x.pattern and x.pattern.pattern or '',),
+ }
+
+ def _crackArgs(self, predicate):
+ cracker = self._KNOWN_PREDICATE_TYPES.get(predicate.PREDICATE_TYPE)
+ if cracker is not None:
+ return cracker(predicate)
+ return () # XXX: raise?
Property changes on: CMF/trunk/CMFCore/exportimport/contenttyperegistry.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py 2005-11-13 19:09:36 UTC (rev 40086)
+++ CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py 2005-11-13 19:55:09 UTC (rev 40087)
@@ -0,0 +1,102 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Caching policy manager node adapter unit tests.
+
+$Id$
+"""
+
+import unittest
+import Testing
+
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
+from Products.GenericSetup.testing import NodeAdapterTestCase
+
+
+_CP_XML = """\
+<caching-policy name="foo_policy" enable_304s="False" etag_func=""
+ last_modified="True" max_age_secs="0" mtime_func="object/modified"
+ must_revalidate="False" no_cache="False" no_store="False"
+ no_transform="False" predicate="python:1" private="False"
+ proxy_revalidate="False" public="False" vary=""/>
+"""
+
+_CPM_XML = """\
+<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"
+ must_revalidate="False" no_cache="False" no_store="False"
+ no_transform="False"
+ predicate="python:object.getPortalTypeName() == 'Foo'" private="False"
+ proxy_revalidate="False" public="False" vary=""/>
+</object>
+"""
+
+
+class CachingPolicyNodeAdapterTests(PlacelessSetup, NodeAdapterTestCase):
+
+ def _getTargetClass(self):
+ from Products.CMFCore.exportimport.cachingpolicymgr \
+ import CachingPolicyNodeAdapter
+
+ return CachingPolicyNodeAdapter
+
+ def setUp(self):
+ from Products.CMFCore.CachingPolicyManager import CachingPolicy
+ import Products.CMFCore.exportimport
+ import Products.Five
+ from Products.Five import zcml
+
+ PlacelessSetup.setUp(self)
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
+
+ self._obj = CachingPolicy('foo_policy', max_age_secs=0)
+ self._XML = _CP_XML
+
+
+class CachingPolicyManagerNodeAdapterTests(PlacelessSetup,
+ NodeAdapterTestCase):
+
+ def _getTargetClass(self):
+ from Products.CMFCore.exportimport.cachingpolicymgr \
+ import CachingPolicyManagerNodeAdapter
+
+ return CachingPolicyManagerNodeAdapter
+
+ def _populate(self, obj):
+ obj.addPolicy('foo_policy',
+ 'python:object.getPortalTypeName() == \'Foo\'',
+ 'object/modified', 600, 0, 0, 0, '', '')
+
+ def setUp(self):
+ from Products.CMFCore.CachingPolicyManager import CachingPolicyManager
+ import Products.CMFCore.exportimport
+ import Products.Five
+ from Products.Five import zcml
+
+ PlacelessSetup.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 test_suite():
+ return unittest.TestSuite((
+ unittest.makeSuite(CachingPolicyNodeAdapterTests),
+ unittest.makeSuite(CachingPolicyManagerNodeAdapterTests),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py 2005-11-13 19:09:36 UTC (rev 40086)
+++ CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py 2005-11-13 19:55:09 UTC (rev 40087)
@@ -0,0 +1,91 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Content type registry node adapter unit tests.
+
+$Id$
+"""
+
+import unittest
+import Testing
+
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
+from Products.GenericSetup.testing import NodeAdapterTestCase
+
+
+_CTR_XML = """\
+<object name="content_type_registry" meta_type="Content Type Registry">
+ <predicate name="foo_predicate" content_type_name="Foo Type"
+ predicate_type="major_minor">
+ <argument value="foo_major"/>
+ <argument value="foo_minor"/>
+ </predicate>
+ <predicate name="bar_predicate" content_type_name="Bar Type"
+ predicate_type="extension">
+ <argument value="bar"/>
+ </predicate>
+ <predicate name="baz_predicate" content_type_name="Baz Type"
+ predicate_type="mimetype_regex">
+ <argument value="baz/.*"/>
+ </predicate>
+ <predicate name="foobar_predicate" content_type_name="Foobar Type"
+ predicate_type="name_regex">
+ <argument value="foobar-.*"/>
+ </predicate>
+</object>
+"""
+
+
+class ContentTypeRegistryNodeAdapterTests(PlacelessSetup,
+ NodeAdapterTestCase):
+
+ def _getTargetClass(self):
+ from Products.CMFCore.exportimport.contenttyperegistry \
+ import ContentTypeRegistryNodeAdapter
+
+ return ContentTypeRegistryNodeAdapter
+
+ def _populate(self, obj):
+ obj.addPredicate('foo_predicate', 'major_minor')
+ obj.getPredicate('foo_predicate').edit('foo_major', 'foo_minor')
+ obj.assignTypeName('foo_predicate', 'Foo Type')
+ obj.addPredicate('bar_predicate', 'extension')
+ obj.getPredicate('bar_predicate').edit('bar')
+ obj.assignTypeName('bar_predicate', 'Bar Type')
+ obj.addPredicate('baz_predicate', 'mimetype_regex')
+ obj.getPredicate('baz_predicate').edit('baz/.*')
+ obj.assignTypeName('baz_predicate', 'Baz Type')
+ obj.addPredicate('foobar_predicate', 'name_regex')
+ obj.getPredicate('foobar_predicate').edit('foobar-.*')
+ obj.assignTypeName('foobar_predicate', 'Foobar Type')
+
+ def setUp(self):
+ from Products.CMFCore.ContentTypeRegistry import ContentTypeRegistry
+ import Products.CMFCore.exportimport
+ import Products.Five
+ from Products.Five import zcml
+
+ PlacelessSetup.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 test_suite():
+ return unittest.TestSuite((
+ unittest.makeSuite(ContentTypeRegistryNodeAdapterTests),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: CMF/trunk/CMFDefault/profiles/default/cachingpolicymgr.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/cachingpolicymgr.xml 2005-11-13 19:09:36 UTC (rev 40086)
+++ CMF/trunk/CMFDefault/profiles/default/cachingpolicymgr.xml 2005-11-13 19:55:09 UTC (rev 40087)
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
-<caching-policies>
+<object name="caching_policy_manager" meta_type="CMF Caching Policy Manager">
<!-- TODO: add some sensible defaults -->
-</caching-policies>
+</object>
Modified: CMF/trunk/CMFDefault/profiles/default/contenttyperegistry.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/contenttyperegistry.xml 2005-11-13 19:09:36 UTC (rev 40086)
+++ CMF/trunk/CMFDefault/profiles/default/contenttyperegistry.xml 2005-11-13 19:55:09 UTC (rev 40087)
@@ -1,28 +1,24 @@
<?xml version="1.0"?>
-<content-type-registry>
- <predicate predicate_id="link" predicate_type="extension"
- content_type_name="Link">
+<object name="content_type_registry" meta_type="Content Type Registry">
+ <predicate name="link" content_type_name="Link" predicate_type="extension">
<argument value="url,link"/>
</predicate>
- <predicate predicate_id="news" predicate_type="extension"
- content_type_name="News Item">
+ <predicate name="news" content_type_name="News Item"
+ predicate_type="extension">
<argument value="news"/>
</predicate>
- <predicate predicate_id="document"
- predicate_type="major_minor"
- content_type_name="Document">
+ <predicate name="document" content_type_name="Document"
+ predicate_type="major_minor">
<argument value="text"/>
<argument value=""/>
</predicate>
- <predicate predicate_id="image"
- predicate_type="major_minor"
- content_type_name="Image">
+ <predicate name="image" content_type_name="Image"
+ predicate_type="major_minor">
<argument value="image"/>
<argument value=""/>
</predicate>
- <predicate predicate_id="file" predicate_type="major_minor"
- content_type_name="File">
+ <predicate name="file" content_type_name="File" predicate_type="major_minor">
<argument value="application"/>
<argument value=""/>
</predicate>
-</content-type-registry>
+</object>
Modified: CMF/trunk/CMFSetup/cachingpolicymgr.py
===================================================================
--- CMF/trunk/CMFSetup/cachingpolicymgr.py 2005-11-13 19:09:36 UTC (rev 40086)
+++ CMF/trunk/CMFSetup/cachingpolicymgr.py 2005-11-13 19:55:09 UTC (rev 40087)
@@ -15,50 +15,35 @@
$Id$
"""
-from AccessControl import ClassSecurityInfo
-from AccessControl.Permission import Permission
-from Globals import InitializeClass
-from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+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
-from permissions import ManagePortal
-from utils import CONVERTER
-from utils import DEFAULT
-from utils import ExportConfiguratorBase
-from utils import ImportConfiguratorBase
-from utils import KEY
-from utils import _xmldir
-
-#
-# Configurator entry points
-#
_FILENAME = 'cachingpolicymgr.xml'
+
def importCachingPolicyManager(context):
- """ Import cache policy maanger settings from an XML file.
+ """ Import caching policy manager settings from an XML file.
"""
site = context.getSite()
- cpm = getToolByName(site, 'caching_policy_manager', None)
- if cpm is None:
- return 'Cache policy manager: No tool!'
+ mode = context.shouldPurge() and PURGE or UPDATE
+ cptool = getToolByName(site, 'caching_policy_manager', None)
body = context.readDataFile(_FILENAME)
if body is None:
- return 'Cache policy manager: Nothing to import.'
+ return 'Caching policy manager: Nothing to import.'
- if context.shouldPurge():
- cpm.__init__()
+ importer = INodeImporter(cptool, None)
+ if importer is None:
+ return 'Caching policy manager: Import adapter misssing.'
- # now act on the settings we've retrieved
- configurator = CachingPolicyManagerImportConfigurator(site)
- cpm_info = configurator.parseXML(body)
+ importer.importNode(parseString(body).documentElement, mode=mode)
+ return 'Caching policy manager settings imported.'
- for policy in cpm_info['policies']:
- cpm.addPolicy(**policy)
-
- return 'Cache policy manager settings imported.'
-
def exportCachingPolicyManager(context):
""" Export caching policy manager settings as an XML file.
"""
@@ -68,79 +53,11 @@
if cptool is None:
return 'Caching policy manager: Nothing to export.'
- mhc = CachingPolicyManagerExportConfigurator( site ).__of__( site )
- text = mhc.generateXML()
+ exporter = INodeExporter(cptool)
+ if exporter is None:
+ return 'Caching policy manager: Export adapter misssing.'
- context.writeDataFile( _FILENAME, text, 'text/xml' )
-
+ doc = PrettyDocument()
+ doc.appendChild(exporter.exportNode(doc))
+ context.writeDataFile(_FILENAME, doc.toprettyxml(' '), 'text/xml')
return 'Caching policy manager settings exported.'
-
-
-class CachingPolicyManagerExportConfigurator(ExportConfiguratorBase):
- """ Synthesize XML description of cc properties.
- """
- security = ClassSecurityInfo()
-
- security.declareProtected( ManagePortal, 'listPolicyInfo' )
- def listPolicyInfo(self):
- """ Return a list of mappings describing the tool's policies.
- """
- cpm = getToolByName(self._site, 'caching_policy_manager')
- for policy_id, policy in cpm.listPolicies():
- yield {'policy_id': policy_id,
- 'predicate': policy.getPredicate(),
- 'mtime_func': policy.getMTimeFunc(),
- 'vary': policy.getVary(),
- 'etag_func': policy.getETagFunc(),
- 'max_age_secs': policy.getMaxAgeSecs(),
- 's_max_age_secs': policy.getSMaxAgeSecs(),
- 'pre_check': policy.getPreCheck(),
- 'post_check': policy.getPostCheck(),
- 'last_modified': bool(policy.getLastModified()),
- 'no_cache': bool(policy.getNoCache()),
- 'no_store': bool(policy.getNoStore()),
- 'must_revalidate': bool(policy.getMustRevalidate()),
- 'proxy_revalidate': bool(policy.getProxyRevalidate()),
- 'no_transform': bool(policy.getNoTransform()),
- 'public': bool(policy.getPublic()),
- 'private': bool(policy.getPrivate()),
- 'enable_304s': bool(policy.getEnable304s()),
- }
-
- security.declarePrivate('_getExportTemplate')
- def _getExportTemplate(self):
-
- return PageTemplateFile('cpmExport.xml', _xmldir)
-
-InitializeClass(CachingPolicyManagerExportConfigurator)
-
-class CachingPolicyManagerImportConfigurator(ImportConfiguratorBase):
-
- def _getImportMapping(self):
- return {
- 'caching-policies':
- { 'caching-policy': {KEY: 'policies', DEFAULT: ()} },
- 'caching-policy':
- { 'policy_id': {},
- 'remove': {},
- 'predicate': {},
- 'mtime_func': {},
- 'vary': {},
- 'etag_func': {},
- 'max_age_secs': {CONVERTER: self._convertToInteger},
- 's_max_age_secs': {CONVERTER: self._convertToInteger},
- 'pre_check': {CONVERTER: self._convertToInteger},
- 'post_check': {CONVERTER: self._convertToInteger},
- 'last_modified': {CONVERTER: self._convertToBoolean},
- 'no_cache': {CONVERTER: self._convertToBoolean},
- 'no_store': {CONVERTER: self._convertToBoolean},
- 'must_revalidate': {CONVERTER: self._convertToBoolean},
- 'proxy_revalidate': {CONVERTER: self._convertToBoolean},
- 'no_transform': {CONVERTER: self._convertToBoolean},
- 'public': {CONVERTER: self._convertToBoolean},
- 'private': {CONVERTER: self._convertToBoolean},
- 'enable_304s': {CONVERTER: self._convertToBoolean},
- },
- }
-
-InitializeClass(CachingPolicyManagerImportConfigurator)
Modified: CMF/trunk/CMFSetup/contenttyperegistry.py
===================================================================
--- CMF/trunk/CMFSetup/contenttyperegistry.py 2005-11-13 19:09:36 UTC (rev 40086)
+++ CMF/trunk/CMFSetup/contenttyperegistry.py 2005-11-13 19:55:09 UTC (rev 40087)
@@ -15,123 +15,49 @@
$Id$
"""
-from AccessControl import ClassSecurityInfo
-from AccessControl.Permission import Permission
-from Globals import InitializeClass
-from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+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
-from permissions import ManagePortal
-from utils import CONVERTER
-from utils import DEFAULT
-from utils import ExportConfiguratorBase
-from utils import ImportConfiguratorBase
-from utils import KEY
-from utils import _xmldir
-
-#
-# Configurator entry points
-#
_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)
- if ctr is None:
- return 'Content type registry: No tool!'
body = context.readDataFile(_FILENAME)
if body is None:
return 'Content type registry: Nothing to import.'
- if context.shouldPurge():
- ctr.__init__()
+ importer = INodeImporter(ctr, None)
+ if importer is None:
+ return 'Content type registry: Import adapter misssing.'
- # now act on the settings we've retrieved
- configurator = ContentTypeRegistryImportConfigurator(site)
- cpm_info = configurator.parseXML(body)
-
- for info in cpm_info['predicates']:
- ctr.addPredicate(info['predicate_id'], info['predicate_type'])
- arguments = [x['value'].encode('ascii') for x in info['arguments']]
- ctr.getPredicate(info['predicate_id']).edit(*arguments)
- ctr.assignTypeName(info['predicate_id'], info['content_type_name'])
-
+ 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()
- mhc = ContentTypeRegistryExportConfigurator( site ).__of__( site )
- text = mhc.generateXML()
- context.writeDataFile( _FILENAME, text, 'text/xml' )
+ ctr = getToolByName(site, 'content_type_registry', None)
+ if ctr is None:
+ return 'Content type registry: Nothing to export.'
- return 'Content type registry settings exported.'
+ exporter = INodeExporter(ctr)
+ if exporter is None:
+ return 'Content type registry: Export adapter misssing.'
-
-class ContentTypeRegistryExportConfigurator(ExportConfiguratorBase):
- """ Synthesize XML description of ctr properties.
- """
- security = ClassSecurityInfo()
-
- security.declareProtected( ManagePortal, 'listPredicateInfo' )
- def listPredicateInfo(self):
- """ Return a list of mappings describing the tool's predicates.
- """
- cpm = getToolByName(self._site, 'content_type_registry')
- for predicate_id, (predicate,
- content_type_name) in cpm.listPredicates():
- yield {'predicate_id': predicate_id,
- 'predicate_type': predicate.PREDICATE_TYPE,
- 'content_type_name' : content_type_name,
- 'arguments' : self._crackArgs(predicate),
- }
-
- _KNOWN_PREDICATE_TYPES = {
- 'major_minor': lambda x: (','.join(x.major), ','.join(x.minor)),
- 'extension': lambda x: (','.join(x.extensions),),
- 'mimetype_regex': lambda x: (x.pattern and x.pattern.pattern,),
- 'name_regex': lambda x: (x.pattern and x.pattern.pattern,),
- }
-
- security.declarePrivate('_crackArgs')
- def _crackArgs(self, predicate):
- """ Crack apart the "edit args" from predicate.
- """
- cracker = self._KNOWN_PREDICATE_TYPES.get(predicate.PREDICATE_TYPE)
- if cracker is not None:
- return cracker(predicate)
- return () # XXX: raise?
-
- security.declarePrivate('_getExportTemplate')
- def _getExportTemplate(self):
-
- return PageTemplateFile('ctrExport.xml', _xmldir)
-
-InitializeClass(ContentTypeRegistryExportConfigurator)
-
-class ContentTypeRegistryImportConfigurator(ImportConfiguratorBase):
-
- def _getImportMapping(self):
- return {
- 'content-type-registry':
- { 'predicate': {KEY: 'predicates', DEFAULT: ()}
- },
- 'predicate':
- { 'predicate_id': {},
- 'remove': {},
- 'predicate_type': {},
- 'content_type_name': {},
- 'argument': {KEY: 'arguments', DEFAULT: ()},
- },
- 'argument':
- { 'value': {},
- },
- }
-
-InitializeClass(ContentTypeRegistryImportConfigurator)
+ doc = PrettyDocument()
+ doc.appendChild(exporter.exportNode(doc))
+ context.writeDataFile(_FILENAME, doc.toprettyxml(' '), 'text/xml')
+ return 'Content type registry settings exported.'
Modified: CMF/trunk/CMFSetup/tests/test_cachingpolicymgr.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_cachingpolicymgr.py 2005-11-13 19:09:36 UTC (rev 40086)
+++ CMF/trunk/CMFSetup/tests/test_cachingpolicymgr.py 2005-11-13 19:55:09 UTC (rev 40087)
@@ -18,12 +18,16 @@
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(BaseRegistryTests):
+class _CachingPolicyManagerSetup(PlacelessSetup, BaseRegistryTests):
POLICY_ID = 'policy_id'
PREDICATE = "python:object.getId() == 'foo'"
@@ -37,44 +41,21 @@
_EMPTY_EXPORT = """\
<?xml version="1.0"?>
-<caching-policies>
-</caching-policies>
+<object name="caching_policy_manager" meta_type="CMF Caching Policy Manager"/>
"""
_WITH_POLICY_EXPORT = """\
<?xml version="1.0"?>
-<caching-policies>
- <caching-policy
- policy_id="%s"
- predicate="%s"
- mtime_func="%s"
- vary="%s"
- etag_func="%s"
- max_age_secs="%d"
- s_max_age_secs="%d"
- pre_check="%d"
- post_check="%d"
- last_modified="False"
- no_cache="True"
- no_store="True"
- must_revalidate="True"
- proxy_revalidate="True"
- no_transform="True"
- public="True"
- private="True"
- enable_304s="True"
- />
-</caching-policies>
-""" % (POLICY_ID,
- PREDICATE,
- MTIME_FUNC,
- VARY,
- ETAG_FUNC,
- MAX_AGE_SECS,
- S_MAX_AGE_SECS,
- PRE_CHECK,
- POST_CHECK,
- )
+<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
@@ -107,69 +88,17 @@
)
return site
-class CachingPolicyManagerExportConfiguratorTests(_CachingPolicyManagerSetup):
+ 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 _getTargetClass(self):
- from Products.CMFSetup.cachingpolicymgr \
- import CachingPolicyManagerExportConfigurator
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
- return CachingPolicyManagerExportConfigurator
- def test_generateXML_empty(self):
- site = self._initSite(with_policy=False)
- configurator = self._makeOne(site).__of__(site)
-
- self._compareDOM(configurator.generateXML(), self._EMPTY_EXPORT)
-
- def test_generateXML_with_policy(self):
- site = self._initSite(with_policy=True)
- configurator = self._makeOne(site).__of__(site)
-
- self._compareDOM(configurator.generateXML(), self._WITH_POLICY_EXPORT)
-
-
-class CachingPolicyManagerImportConfiguratorTests(_CachingPolicyManagerSetup):
-
- def _getTargetClass(self):
- from Products.CMFSetup.cachingpolicymgr \
- import CachingPolicyManagerImportConfigurator
-
- return CachingPolicyManagerImportConfigurator
-
- def test_parseXML_empty(self):
- site = self._initSite(with_policy=False)
- configurator = self._makeOne(site)
- cpm_info = configurator.parseXML(self._EMPTY_EXPORT)
-
- self.assertEqual(len(cpm_info['policies']), 0)
-
- def test_parseXML_with_policy(self):
- site = self._initSite(with_policy=False)
- configurator = self._makeOne(site)
- cpm_info = configurator.parseXML(self._WITH_POLICY_EXPORT)
-
- self.assertEqual(len(cpm_info['policies']), 1)
-
- info = cpm_info['policies'][0]
- self.assertEqual(info['policy_id'], self.POLICY_ID)
- self.assertEqual(info['predicate'], self.PREDICATE)
- self.assertEqual(info['mtime_func'], self.MTIME_FUNC)
- self.assertEqual(info['vary'], self.VARY)
- self.assertEqual(info['etag_func'], self.ETAG_FUNC)
- self.assertEqual(info['max_age_secs'], self.MAX_AGE_SECS)
- self.assertEqual(info['s_max_age_secs'], self.S_MAX_AGE_SECS)
- self.assertEqual(info['pre_check'], self.PRE_CHECK)
- self.assertEqual(info['post_check'], self.POST_CHECK)
- self.assertEqual(info['last_modified'], False)
- self.assertEqual(info['no_cache'], True)
- self.assertEqual(info['no_store'], True)
- self.assertEqual(info['must_revalidate'], True)
- self.assertEqual(info['proxy_revalidate'], True)
- self.assertEqual(info['no_transform'], True)
- self.assertEqual(info['public'], True)
- self.assertEqual(info['private'], True)
- self.assertEqual(info['enable_304s'], True)
-
class Test_exportCachingPolicyManager(_CachingPolicyManagerSetup):
def test_empty(self):
@@ -240,8 +169,6 @@
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(CachingPolicyManagerExportConfiguratorTests),
- unittest.makeSuite(CachingPolicyManagerImportConfiguratorTests),
unittest.makeSuite(Test_exportCachingPolicyManager),
unittest.makeSuite(Test_importCachingPolicyManager),
))
Modified: CMF/trunk/CMFSetup/tests/test_contenttyperegistry.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_contenttyperegistry.py 2005-11-13 19:09:36 UTC (rev 40086)
+++ CMF/trunk/CMFSetup/tests/test_contenttyperegistry.py 2005-11-13 19:55:09 UTC (rev 40087)
@@ -18,6 +18,10 @@
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
@@ -29,7 +33,7 @@
('logfiles', 'name_regex', ('error_log-.*',), 'Log File'),
)
-class _ContentTypeRegistrySetup(BaseRegistryTests):
+class _ContentTypeRegistrySetup(PlacelessSetup, BaseRegistryTests):
MAJOR_MINOR_ID = _TEST_PREDICATES[0][0]
MAJOR = _TEST_PREDICATES[0][2][0]
@@ -47,39 +51,30 @@
_EMPTY_EXPORT = """\
<?xml version="1.0"?>
-<content-type-registry>
-</content-type-registry>
+<object name="content_type_registry" meta_type="Content Type Registry"/>
"""
_WITH_POLICY_EXPORT = """\
<?xml version="1.0"?>
-<content-type-registry>
- <predicate
- predicate_id="%s"
- predicate_type="major_minor"
- content_type_name="%s">
- <argument value="%s" />
- <argument value="%s" />
+<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
- predicate_id="%s"
- predicate_type="extension"
- content_type_name="%s">
- <argument value="%s" />
+ <predicate name="%s" content_type_name="%s"
+ predicate_type="extension">
+ <argument value="%s"/>
</predicate>
- <predicate
- predicate_id="%s"
- predicate_type="mimetype_regex"
- content_type_name="%s">
- <argument value="%s" />
+ <predicate name="%s" content_type_name="%s"
+ predicate_type="mimetype_regex">
+ <argument value="%s"/>
</predicate>
- <predicate
- predicate_id="%s"
- predicate_type="name_regex"
- content_type_name="%s">
- <argument value="%s" />
+ <predicate name="%s" content_type_name="%s"
+ predicate_type="name_regex">
+ <argument value="%s"/>
</predicate>
-</content-type-registry>
+</object>
""" % (MAJOR_MINOR_ID,
MAJOR_MINOR_TYPENAME,
MAJOR,
@@ -114,84 +109,17 @@
return site
-class ContentTypeRegistryExportConfiguratorTests(_ContentTypeRegistrySetup):
+ 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 _getTargetClass(self):
- from Products.CMFSetup.contenttyperegistry \
- import ContentTypeRegistryExportConfigurator
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
- return ContentTypeRegistryExportConfigurator
- def test_generateXML_empty(self):
- site = self._initSite(mit_predikat=False)
- configurator = self._makeOne(site).__of__(site)
-
- self._compareDOM(configurator.generateXML(), self._EMPTY_EXPORT)
-
- def test_generateXML_with_policy(self):
- site = self._initSite(mit_predikat=True)
- configurator = self._makeOne(site).__of__(site)
-
- self._compareDOM(configurator.generateXML(), self._WITH_POLICY_EXPORT)
-
-
-class ContentTypeRegistryImportConfiguratorTests(_ContentTypeRegistrySetup):
-
- def _getTargetClass(self):
- from Products.CMFSetup.contenttyperegistry \
- import ContentTypeRegistryImportConfigurator
-
- return ContentTypeRegistryImportConfigurator
-
- def test_parseXML_empty(self):
- site = self._initSite(mit_predikat=False)
- configurator = self._makeOne(site)
- ctr_info = configurator.parseXML(self._EMPTY_EXPORT)
-
- self.assertEqual(len(ctr_info['predicates']), 0)
-
- def test_parseXML_with_policy(self):
- site = self._initSite(mit_predikat=False)
- configurator = self._makeOne(site)
- ctr_info = configurator.parseXML(self._WITH_POLICY_EXPORT)
-
- self.assertEqual(len(ctr_info['predicates']), len(_TEST_PREDICATES))
-
- info = ctr_info['predicates'][0]
- self.assertEqual(info['predicate_id'], self.MAJOR_MINOR_ID)
- self.assertEqual(info['predicate_type'], 'major_minor')
- self.assertEqual(info['content_type_name'], self.MAJOR_MINOR_TYPENAME)
- arguments = info['arguments']
- self.assertEqual(len(arguments), 2)
- self.assertEqual(arguments[0]['value'], self.MAJOR)
- self.assertEqual(arguments[1]['value'], self.MINOR)
-
- info = ctr_info['predicates'][1]
- self.assertEqual(info['predicate_id'], self.EXTENSION_ID)
- self.assertEqual(info['predicate_type'], 'extension')
- self.assertEqual(info['content_type_name'], self.EXTENSION_TYPENAME)
- arguments = info['arguments']
- self.assertEqual(len(arguments), 1)
- self.assertEqual(arguments[0]['value'], self.EXTENSIONS)
-
- info = ctr_info['predicates'][2]
- self.assertEqual(info['predicate_id'], self.MIMETYPE_REGEX_ID)
- self.assertEqual(info['predicate_type'], 'mimetype_regex')
- self.assertEqual(info['content_type_name'],
- self.MIMETYPE_REGEX_TYPENAME)
- arguments = info['arguments']
- self.assertEqual(len(arguments), 1)
- self.assertEqual(arguments[0]['value'], self.MIMETYPE_REGEX)
-
- info = ctr_info['predicates'][3]
- self.assertEqual(info['predicate_id'], self.NAME_REGEX_ID)
- self.assertEqual(info['predicate_type'], 'name_regex')
- self.assertEqual(info['content_type_name'],
- self.NAME_REGEX_TYPENAME)
- arguments = info['arguments']
- self.assertEqual(len(arguments), 1)
- self.assertEqual(arguments[0]['value'], self.NAME_REGEX)
-
class Test_exportContentTypeRegistry(_ContentTypeRegistrySetup):
def test_empty(self):
@@ -267,12 +195,9 @@
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(ContentTypeRegistryExportConfiguratorTests),
- unittest.makeSuite(ContentTypeRegistryImportConfiguratorTests),
unittest.makeSuite(Test_exportContentTypeRegistry),
unittest.makeSuite(Test_importContentTypeRegistry),
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
-
Deleted: CMF/trunk/CMFSetup/xml/cpmExport.xml
===================================================================
--- CMF/trunk/CMFSetup/xml/cpmExport.xml 2005-11-13 19:09:36 UTC (rev 40086)
+++ CMF/trunk/CMFSetup/xml/cpmExport.xml 2005-11-13 19:55:09 UTC (rev 40087)
@@ -1,43 +0,0 @@
-<?xml version="1.0"?>
-<caching-policies xmlns:tal="http://xml.zope.org/namespaces/tal">
- <caching-policy
- policy_id="POLICY_ID"
- predicate="PREDICATE"
- mtime_func="MTIME_FUNC"
- vary="VARY"
- etag_func="ETAG_FUNC"
- max_age_secs="MAX_AGE_SECS"
- s_max_age_secs="S_MAX_AGE_SECS"
- pre_check="PRE_CHECK"
- post_check="POST_CHECK"
- last_modified="LAST_MODIFIED"
- no_cache="NO_CACHE"
- no_store="NO_STORE"
- must_revalidate="MUST_REVALIDATE"
- proxy_revalidate="PROXY_REVALIDATE"
- no_transform="NO_TRANSFORM"
- public="PUBLIC"
- private="PRIVATE"
- enable_304s="ENABLE_304S"
- tal:repeat="info context/listPolicyInfo"
- tal:attributes="policy_id info/policy_id;
- predicate info/predicate;
- mtime_func info/mtime_func;
- vary info/vary;
- etag_func info/etag_func;
- max_age_secs info/max_age_secs;
- s_max_age_secs info/s_max_age_secs;
- pre_check info/pre_check;
- post_check info/post_check;
- last_modified info/last_modified;
- no_cache info/no_cache;
- no_store info/no_store;
- must_revalidate info/must_revalidate;
- proxy_revalidate info/proxy_revalidate;
- no_transform info/no_transform;
- public info/public;
- private info/private;
- enable_304s info/enable_304s;
- "
- />
-</caching-policies>
Deleted: CMF/trunk/CMFSetup/xml/ctrExport.xml
===================================================================
--- CMF/trunk/CMFSetup/xml/ctrExport.xml 2005-11-13 19:09:36 UTC (rev 40086)
+++ CMF/trunk/CMFSetup/xml/ctrExport.xml 2005-11-13 19:55:09 UTC (rev 40087)
@@ -1,17 +0,0 @@
-<?xml version="1.0"?>
-<content-type-registry xmlns:tal="http://xml.zope.org/namespaces/tal">
- <predicate
- predicate_id="PREDICATE_ID"
- predicate_type="PREDICATE_TYPE"
- content_type_name="CONTENT_TYPE_NAME"
- tal:repeat="info context/listPredicateInfo"
- tal:attributes="predicate_id info/predicate_id;
- predicate_type info/predicate_type;
- content_type_name info/content_type_name; " >
- <argument
- value="ARGUMENT_VALUE"
- tal:repeat="arg info/arguments"
- tal:attributes="value arg"
- />
- </predicate>
-</content-type-registry>
More information about the CMF-checkins
mailing list