[CMF-checkins] SVN: CMF/trunk/ - implemented
PropertyManagerHelpers._purgeProperties
Yvo Schubbe
y.2005- at wcm-solutions.de
Sun Nov 6 11:41:16 EST 2005
Log message for revision 39947:
- implemented PropertyManagerHelpers._purgeProperties
- declared PortalObjectBase implements ISiteRoot
- converted site properties setup handlers to new style
- marked generic object and property support in *ConfiguratorBase as deprecated
- updated CMFDefault default profile
Changed:
U CMF/trunk/CMFCore/PortalObject.py
U CMF/trunk/CMFCore/exportimport/actions.py
U CMF/trunk/CMFCore/exportimport/configure.zcml
A CMF/trunk/CMFCore/exportimport/properties.py
A CMF/trunk/CMFCore/exportimport/tests/test_properties.py
U CMF/trunk/CMFDefault/profiles/default/properties.xml
U CMF/trunk/CMFSetup/properties.py
U CMF/trunk/CMFSetup/tests/test_actions.py
U CMF/trunk/CMFSetup/tests/test_properties.py
U CMF/trunk/CMFSetup/tests/test_utils.py
U CMF/trunk/CMFSetup/utils.py
D CMF/trunk/CMFSetup/xml/spcExport.xml
U CMF/trunk/GenericSetup/utils.py
D CMF/trunk/GenericSetup/xml/spcExport.xml
-=-
Modified: CMF/trunk/CMFCore/PortalObject.py
===================================================================
--- CMF/trunk/CMFCore/PortalObject.py 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/CMFCore/PortalObject.py 2005-11-06 16:41:15 UTC (rev 39947)
@@ -16,21 +16,24 @@
"""
from Globals import InitializeClass
+from zope.interface import implements
-from PortalFolder import PortalFolder
-from Skinnable import SkinnableObjectManager
+from interfaces import ISiteRoot
from permissions import AddPortalMember
from permissions import SetOwnPassword
from permissions import SetOwnProperties
from permissions import MailForgottenPassword
from permissions import RequestReview
from permissions import ReviewPortalContent
+from PortalFolder import PortalFolder
+from Skinnable import SkinnableObjectManager
PORTAL_SKINS_TOOL_ID = 'portal_skins'
class PortalObjectBase(PortalFolder, SkinnableObjectManager):
+ implements(ISiteRoot)
meta_type = 'Portal Site'
_isPortalRoot = 1
Modified: CMF/trunk/CMFCore/exportimport/actions.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/actions.py 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/CMFCore/exportimport/actions.py 2005-11-06 16:41:15 UTC (rev 39947)
@@ -78,6 +78,9 @@
def importNode(self, node, mode=PURGE):
"""Import the object from the DOM node.
"""
+ if mode == PURGE:
+ self._purgeProperties()
+
self._initProperties(node, mode)
Modified: CMF/trunk/CMFCore/exportimport/configure.zcml
===================================================================
--- CMF/trunk/CMFCore/exportimport/configure.zcml 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/CMFCore/exportimport/configure.zcml 2005-11-06 16:41:15 UTC (rev 39947)
@@ -101,6 +101,18 @@
/>
<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=".typeinfo.TypeInformationNodeAdapter"
provides="Products.GenericSetup.interfaces.INodeExporter"
for="Products.CMFCore.interfaces.ITypeInformation"
Added: CMF/trunk/CMFCore/exportimport/properties.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/properties.py 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/CMFCore/exportimport/properties.py 2005-11-06 16:41:15 UTC (rev 39947)
@@ -0,0 +1,46 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Site properties node adapters.
+
+$Id$
+"""
+
+from Products.GenericSetup.interfaces import PURGE
+from Products.GenericSetup.utils import NodeAdapterBase
+from Products.GenericSetup.utils import PropertyManagerHelpers
+
+from Products.CMFCore.interfaces import ISiteRoot
+
+
+class PropertiesNodeAdapter(NodeAdapterBase, PropertyManagerHelpers):
+
+ """Node im- and exporter for properties.
+ """
+
+ __used_for__ = ISiteRoot
+
+ def exportNode(self, doc):
+ """Export the object as a DOM node.
+ """
+ self._doc = doc
+ node = self._doc.createElement('site')
+ node.appendChild(self._extractProperties())
+ return node
+
+ def importNode(self, node, mode=PURGE):
+ """Import the object from the DOM node.
+ """
+ if mode == PURGE:
+ self._purgeProperties()
+
+ self._initProperties(node, mode)
Property changes on: CMF/trunk/CMFCore/exportimport/properties.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: CMF/trunk/CMFCore/exportimport/tests/test_properties.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_properties.py 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/CMFCore/exportimport/tests/test_properties.py 2005-11-06 16:41:15 UTC (rev 39947)
@@ -0,0 +1,68 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Site properties node adapter unit tests.
+
+$Id$
+"""
+
+import unittest
+import Testing
+
+import Products.CMFCore.exportimport
+import Products.Five
+from Products.Five import zcml
+from zope.app.tests.placelesssetup import PlacelessSetup
+
+from Products.GenericSetup.testing import NodeAdapterTestCase
+
+
+_PROPERTIES_XML = """\
+<site>
+ <property name="title">Foo</property>
+ <property name="foo_string" type="string">foo</property>
+ <property name="foo_boolean" type="boolean">False</property>
+</site>
+"""
+
+
+class PropertiesNodeAdapterTests(PlacelessSetup, NodeAdapterTestCase):
+
+ def _getTargetClass(self):
+ from Products.CMFCore.exportimport.properties \
+ import PropertiesNodeAdapter
+
+ return PropertiesNodeAdapter
+
+ def _populate(self, obj):
+ obj._setPropValue('title', 'Foo')
+ obj._setProperty('foo_string', 'foo', 'string')
+ obj._setProperty('foo_boolean', False, 'boolean')
+
+ def setUp(self):
+ from Products.CMFCore.PortalObject import PortalObjectBase
+
+ PlacelessSetup.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 test_suite():
+ return unittest.TestSuite((
+ unittest.makeSuite(PropertiesNodeAdapterTests),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: CMF/trunk/CMFCore/exportimport/tests/test_properties.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: CMF/trunk/CMFDefault/profiles/default/properties.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/properties.xml 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/CMFDefault/profiles/default/properties.xml 2005-11-06 16:41:15 UTC (rev 39947)
@@ -1,10 +1,12 @@
<?xml version="1.0"?>
<site>
- <property name="title">Portal</property>
- <property name="description"></property>
- <property name="email_from_address" type="string">postmaster at localhost</property>
- <property name="email_from_name" type="string">Portal Administrator</property>
- <property name="validate_email" type="boolean">False</property>
- <property name="default_charset" type="string"></property>
- <property name="enable_permalink" type="boolean">False</property>
+ <property name="title">Portal</property>
+ <property name="description"></property>
+ <property name="email_from_address"
+ type="string">postmaster at localhost</property>
+ <property name="email_from_name"
+ type="string">Portal Administrator</property>
+ <property name="validate_email" type="boolean">False</property>
+ <property name="default_charset" type="string"></property>
+ <property name="enable_permalink" type="boolean">False</property>
</site>
Modified: CMF/trunk/CMFSetup/properties.py
===================================================================
--- CMF/trunk/CMFSetup/properties.py 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/CMFSetup/properties.py 2005-11-06 16:41:15 UTC (rev 39947)
@@ -10,88 +10,48 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-""" Site properties setup handlers.
+"""Site properties setup handlers.
$Id$
"""
-from AccessControl import ClassSecurityInfo
-from Globals import InitializeClass
-from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from xml.dom.minidom import parseString
-from permissions import ManagePortal
-from utils import _xmldir
-from utils import ConfiguratorBase
-from utils import DEFAULT, KEY
+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
-
-#
-# Configurator entry points
-#
_FILENAME = 'properties.xml'
+
def importSiteProperties(context):
""" Import site properties from an XML file.
"""
site = context.getSite()
- encoding = context.getEncoding()
+ mode = context.shouldPurge() and PURGE or UPDATE
- if context.shouldPurge():
-
- for prop_map in site._propertyMap():
- prop_id = prop_map['id']
- if 'd' in prop_map.get('mode', 'wd') and \
- prop_id not in ('title', 'description'):
- site._delProperty(prop_id)
- else:
- if prop_map.get('type') == 'multiple selection':
- prop_value = ()
- else:
- prop_value = ''
- site._updateProperty(prop_id, prop_value)
-
- xml = context.readDataFile(_FILENAME)
- if xml is None:
+ body = context.readDataFile(_FILENAME)
+ if body is None:
return 'Site properties: Nothing to import.'
- spc = SitePropertiesConfigurator(site, encoding)
- site_info = spc.parseXML(xml)
+ importer = INodeImporter(site, None)
+ if importer is None:
+ return 'Site properties: Import adapter misssing.'
- for prop_info in site_info['properties']:
- spc.initProperty(site, prop_info)
-
+ importer.importNode(parseString(body).documentElement, mode=mode)
return 'Site properties imported.'
def exportSiteProperties(context):
""" Export site properties as an XML file.
"""
site = context.getSite()
- spc = SitePropertiesConfigurator(site).__of__(site)
- xml = spc.generateXML()
- context.writeDataFile(_FILENAME, xml, 'text/xml')
+ 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.'
-
-
-class SitePropertiesConfigurator(ConfiguratorBase):
- """ Synthesize XML description of site's properties.
- """
- security = ClassSecurityInfo()
-
- security.declareProtected(ManagePortal, 'listSiteInfos')
- def listSiteInfos(self):
- """ Get a sequence of mappings for site properties.
- """
- return tuple( [ self._extractProperty(self._site, prop_map)
- for prop_map in self._site._propertyMap() ] )
-
- def _getExportTemplate(self):
-
- return PageTemplateFile('spcExport.xml', _xmldir)
-
- def _getImportMapping(self):
-
- return { 'site': { 'property': {KEY: 'properties', DEFAULT: () } } }
-
-InitializeClass(SitePropertiesConfigurator)
Modified: CMF/trunk/CMFSetup/tests/test_actions.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_actions.py 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/CMFSetup/tests/test_actions.py 2005-11-06 16:41:15 UTC (rev 39947)
@@ -124,7 +124,7 @@
PlacelessSetup.setUp(self)
BaseRegistryTests.setUp(self)
zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.CMFCore)
+ zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
def tearDown(self):
BaseRegistryTests.tearDown(self)
Modified: CMF/trunk/CMFSetup/tests/test_properties.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_properties.py 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/CMFSetup/tests/test_properties.py 2005-11-06 16:41:15 UTC (rev 39947)
@@ -14,12 +14,14 @@
$Id$
"""
+
import unittest
import Testing
-import Zope2
-Zope2.startup()
-from OFS.Folder import Folder
+import Products
+from Products.Five import zcml
+from Products.CMFCore.PortalObject import PortalObjectBase
+from zope.app.tests.placelesssetup import PlacelessSetup
from common import BaseRegistryTests
from common import DummyExportContext
@@ -27,33 +29,32 @@
_EMPTY_EXPORT = """\
-<?xml version="1.0"?>
+<?xml version="1.0" ?>
<site>
+ <property name="title"/>
</site>
"""
_NORMAL_EXPORT = """\
-<?xml version="1.0"?>
+<?xml version="1.0" ?>
<site>
- <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>
+ <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 DummySite(Folder):
+class _SitePropertiesSetup(PlacelessSetup, BaseRegistryTests):
- _properties = ()
-
-
-class _SitePropertiesSetup(BaseRegistryTests):
-
def _initSite(self, foo=2, bar=2):
- self.root.site = DummySite()
+ self.root.site = PortalObjectBase('foo_site')
site = self.root.site
if foo > 0:
@@ -70,109 +71,40 @@
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)
-class SitePropertiesConfiguratorTests(_SitePropertiesSetup):
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
- def _getTargetClass(self):
- from Products.CMFSetup.properties import SitePropertiesConfigurator
- return SitePropertiesConfigurator
-
- def test_listSiteInfos_normal(self):
-
- site = self._initSite()
-
- EXPECTED = [ { 'id': 'foo',
- 'value': 'Foo',
- 'elements': (),
- 'type': 'string',
- 'select_variable': None },
- { 'id': 'bar',
- 'value': '',
- 'elements': ('Bar',),
- 'type': 'tokens',
- 'select_variable': None },
- { 'id': 'moo',
- 'value': '',
- 'elements': ('Moo',),
- 'type': 'tokens',
- 'select_variable': None } ]
-
- configurator = self._makeOne(site)
-
- site_info = configurator.listSiteInfos()
- self.assertEqual( len(site_info), len(EXPECTED) )
-
- for found, expected in zip(site_info, EXPECTED):
- self.assertEqual(found, expected)
-
- def test_generateXML_empty(self):
-
- site = self._initSite(0, 0)
- configurator = self._makeOne(site).__of__(site)
-
- self._compareDOM(configurator.generateXML(), _EMPTY_EXPORT)
-
- def test_generateXML_normal(self):
-
- site = self._initSite()
- configurator = self._makeOne(site).__of__(site)
-
- self._compareDOM( configurator.generateXML(), _NORMAL_EXPORT )
-
- def test_parseXML_empty(self):
-
- site = self._initSite(0, 0)
- configurator = self._makeOne(site)
- site_info = configurator.parseXML(_EMPTY_EXPORT)
-
- self.assertEqual( len( site_info['properties'] ), 0 )
-
- def test_parseXML_normal(self):
-
- site = self._initSite()
- configurator = self._makeOne(site)
- site_info = configurator.parseXML(_NORMAL_EXPORT)
-
- self.assertEqual( len( site_info['properties'] ), 3 )
-
- info = site_info['properties'][0]
- self.assertEqual( info['id'], 'foo' )
- self.assertEqual( info['value'], 'Foo' )
- self.assertEqual( len( info['elements'] ), 0 )
-
- info = site_info['properties'][1]
- self.assertEqual( info['id'], 'bar' )
- self.assertEqual( info['value'], '' )
- self.assertEqual( len( info['elements'] ), 1 )
- self.assertEqual( info['elements'][0], 'Bar' )
-
-
class Test_exportSiteProperties(_SitePropertiesSetup):
def test_empty(self):
+ from Products.CMFSetup.properties import exportSiteProperties
site = self._initSite(0, 0)
context = DummyExportContext(site)
-
- from Products.CMFSetup.properties import exportSiteProperties
exportSiteProperties(context)
- self.assertEqual( len(context._wrote), 1 )
+ 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 )
-
- from Products.CMFSetup.properties import exportSiteProperties
exportSiteProperties(context)
- self.assertEqual( len(context._wrote), 1 )
+ self.assertEqual(len(context._wrote), 1)
filename, text, content_type = context._wrote[0]
self.assertEqual(filename, 'properties.xml')
self._compareDOM(text, _NORMAL_EXPORT)
@@ -182,10 +114,11 @@
class Test_importSiteProperties(_SitePropertiesSetup):
def test_empty_default_purge(self):
+ from Products.CMFSetup.properties import importSiteProperties
site = self._initSite()
- self.assertEqual( len( site.propertyIds() ), 3 )
+ self.assertEqual( len( site.propertyIds() ), 4 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
@@ -193,17 +126,16 @@
context = DummyImportContext(site)
context._files['properties.xml'] = _EMPTY_EXPORT
-
- from Products.CMFSetup.properties import importSiteProperties
importSiteProperties(context)
- self.assertEqual( len( site.propertyIds() ), 0 )
+ 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() ), 3 )
+ self.assertEqual( len( site.propertyIds() ), 4 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
@@ -211,17 +143,16 @@
context = DummyImportContext(site, True)
context._files['properties.xml'] = _EMPTY_EXPORT
-
- from Products.CMFSetup.properties import importSiteProperties
importSiteProperties(context)
- self.assertEqual( len( site.propertyIds() ), 0 )
+ 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() ), 3 )
+ self.assertEqual( len( site.propertyIds() ), 4 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
@@ -229,56 +160,34 @@
context = DummyImportContext(site, False)
context._files['properties.xml'] = _EMPTY_EXPORT
-
- from Products.CMFSetup.properties import importSiteProperties
importSiteProperties(context)
- self.assertEqual( len( site.propertyIds() ), 3 )
+ 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() ), 0 )
+ self.assertEqual( len( site.propertyIds() ), 1 )
context = DummyImportContext(site)
context._files['properties.xml'] = _NORMAL_EXPORT
-
- from Products.CMFSetup.properties import importSiteProperties
importSiteProperties(context)
- self.assertEqual( len( site.propertyIds() ), 3 )
+ 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_encode_as_ascii(self):
- site = self._initSite(0,0)
-
- self.assertEqual( len( site.propertyIds() ), 0 )
-
- context = DummyImportContext(site, encoding='ascii')
- context._files['properties.xml'] = _NORMAL_EXPORT
-
- from Products.CMFSetup.properties import importSiteProperties
- importSiteProperties(context)
-
- self.assertEqual( len( site.propertyIds() ), 3 )
- 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(SitePropertiesConfiguratorTests),
unittest.makeSuite(Test_exportSiteProperties),
unittest.makeSuite(Test_importSiteProperties),
))
Modified: CMF/trunk/CMFSetup/tests/test_utils.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_utils.py 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/CMFSetup/tests/test_utils.py 2005-11-06 16:41:15 UTC (rev 39947)
@@ -23,6 +23,8 @@
from DateTime.DateTime import DateTime
from OFS.Folder import Folder
+from Products.CMFCore.tests.base.testcase import WarningInterceptor
+
from common import BaseRegistryTests
@@ -173,7 +175,7 @@
_properties = ()
-class _ConfiguratorBaseTests(BaseRegistryTests):
+class _ConfiguratorBaseTests(WarningInterceptor, BaseRegistryTests):
def _initSite(self, foo=2):
@@ -214,7 +216,15 @@
return site
+ def setUp(self):
+ BaseRegistryTests.setUp(self)
+ self._trap_warning_output()
+ def tearDown(self):
+ self._free_warning_output()
+ BaseRegistryTests.tearDown(self)
+
+
class ExportConfiguratorBaseTests(_ConfiguratorBaseTests):
def _getTargetClass(self):
Modified: CMF/trunk/CMFSetup/utils.py
===================================================================
--- CMF/trunk/CMFSetup/utils.py 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/CMFSetup/utils.py 2005-11-06 16:41:15 UTC (rev 39947)
@@ -16,6 +16,7 @@
"""
import os
+from warnings import warn
from xml.dom.minidom import parseString as domParseString
import Products
@@ -149,6 +150,9 @@
security.declareProtected(ManagePortal, 'initObject')
def initObject(self, parent, o_info):
+ warn('CMFSetup.utils including ImportConfiguratorBase is deprecated. '
+ 'Please use NodeAdapterBase from GenericSetup.utils instead.',
+ DeprecationWarning)
obj_id = str(o_info['id'])
if obj_id not in parent.objectIds():
@@ -189,6 +193,9 @@
security.declareProtected(ManagePortal, 'initProperty')
def initProperty(self, obj, p_info):
+ warn('CMFSetup.utils including ImportConfiguratorBase is deprecated. '
+ 'Please use NodeAdapterBase from GenericSetup.utils instead.',
+ DeprecationWarning)
prop_id = p_info['id']
prop_map = obj.propdict().get(prop_id, None)
@@ -250,6 +257,10 @@
def generateObjectNodes(self, obj_infos):
""" Pseudo API.
"""
+ warn('CMFSetup.utils including ExportConfiguratorBase is deprecated. '
+ 'Please use NodeAdapterBase from GenericSetup.utils instead.',
+ DeprecationWarning)
+
lines = self._ob_nodes(objects=obj_infos).splitlines()
return '\n'.join(lines)
@@ -257,10 +268,17 @@
def generatePropertyNodes(self, prop_infos):
""" Pseudo API.
"""
+ warn('CMFSetup.utils including ExportConfiguratorBase is deprecated. '
+ 'Please use NodeAdapterBase from GenericSetup.utils instead.',
+ DeprecationWarning)
+
lines = self._prop_nodes(properties=prop_infos).splitlines()
return '\n'.join(lines)
def _extractObject(self, obj):
+ warn('CMFSetup.utils including ExportConfiguratorBase is deprecated. '
+ 'Please use NodeAdapterBase from GenericSetup.utils instead.',
+ DeprecationWarning)
properties = []
subobjects = []
@@ -285,6 +303,9 @@
'subobjects': tuple(subobjects) }
def _extractProperty(self, obj, prop_map):
+ warn('CMFSetup.utils including ExportConfiguratorBase is deprecated. '
+ 'Please use NodeAdapterBase from GenericSetup.utils instead.',
+ DeprecationWarning)
prop_id = prop_map['id']
prop = obj.getProperty(prop_id)
Deleted: CMF/trunk/CMFSetup/xml/spcExport.xml
===================================================================
--- CMF/trunk/CMFSetup/xml/spcExport.xml 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/CMFSetup/xml/spcExport.xml 2005-11-06 16:41:15 UTC (rev 39947)
@@ -1,5 +0,0 @@
-<?xml version="1.0"?>
-<site xmlns:tal="http://xml.zope.org/namespaces/tal"
-><tal:span tal:define="prop_infos context/listSiteInfos"
- tal:replace="structure python: context.generatePropertyNodes(prop_infos)"/>
-</site>
Modified: CMF/trunk/GenericSetup/utils.py
===================================================================
--- CMF/trunk/GenericSetup/utils.py 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/GenericSetup/utils.py 2005-11-06 16:41:15 UTC (rev 39947)
@@ -542,8 +542,16 @@
return fragment
def _purgeProperties(self):
- #XXX: not implemented
- pass
+ for prop_map in self.context._propertyMap():
+ prop_id = prop_map['id']
+ if 'd' in prop_map.get('mode', 'wd') and not prop_id == 'title':
+ self.context._delProperty(prop_id)
+ else:
+ if prop_map.get('type') == 'multiple selection':
+ prop_value = ()
+ else:
+ prop_value = ''
+ self.context._updateProperty(prop_id, prop_value)
def _initProperties(self, node, mode):
self.context.i18n_domain = node.getAttribute('i18n:domain')
Deleted: CMF/trunk/GenericSetup/xml/spcExport.xml
===================================================================
--- CMF/trunk/GenericSetup/xml/spcExport.xml 2005-11-06 16:16:10 UTC (rev 39946)
+++ CMF/trunk/GenericSetup/xml/spcExport.xml 2005-11-06 16:41:15 UTC (rev 39947)
@@ -1,5 +0,0 @@
-<?xml version="1.0"?>
-<site xmlns:tal="http://xml.zope.org/namespaces/tal"
-><tal:span tal:define="prop_infos context/listSiteInfos"
- tal:replace="structure python: context.generatePropertyNodes(prop_infos)"/>
-</site>
More information about the CMF-checkins
mailing list