[CMF-checkins] SVN: CMF/branches/goldegg-phase-1/GenericSetup/ Remove CMF-specific properties tool handler.

Tres Seaver tseaver at palladion.com
Sat Sep 24 05:22:36 EDT 2005


Log message for revision 38576:
  Remove CMF-specific properties tool handler.

Changed:
  D   CMF/branches/goldegg-phase-1/GenericSetup/properties.py
  D   CMF/branches/goldegg-phase-1/GenericSetup/tests/test_properties.py

-=-
Deleted: CMF/branches/goldegg-phase-1/GenericSetup/properties.py
===================================================================
--- CMF/branches/goldegg-phase-1/GenericSetup/properties.py	2005-09-24 09:01:32 UTC (rev 38575)
+++ CMF/branches/goldegg-phase-1/GenericSetup/properties.py	2005-09-24 09:22:36 UTC (rev 38576)
@@ -1,97 +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 setup handlers.
-
-$Id$
-"""
-
-from AccessControl import ClassSecurityInfo
-from Globals import InitializeClass
-from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-
-from permissions import ManagePortal
-from utils import _xmldir
-from utils import ConfiguratorBase
-from utils import DEFAULT, KEY
-
-
-#
-#   Configurator entry points
-#
-_FILENAME = 'properties.xml'
-
-def importSiteProperties(context):
-    """ Import site properties from an XML file.
-    """
-    site = context.getSite()
-    encoding = context.getEncoding()
-
-    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:
-        return 'Site properties: Nothing to import.'
-
-    spc = SitePropertiesConfigurator(site, encoding)
-    site_info = spc.parseXML(xml)
-
-    for prop_info in site_info['properties']:
-        spc.initProperty(site, prop_info)
-
-    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')
-
-    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)

Deleted: CMF/branches/goldegg-phase-1/GenericSetup/tests/test_properties.py
===================================================================
--- CMF/branches/goldegg-phase-1/GenericSetup/tests/test_properties.py	2005-09-24 09:01:32 UTC (rev 38575)
+++ CMF/branches/goldegg-phase-1/GenericSetup/tests/test_properties.py	2005-09-24 09:22:36 UTC (rev 38576)
@@ -1,291 +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
-try:
-    import Zope2
-except ImportError: # BBB: for Zope 2.7
-    import Zope as Zope2
-Zope2.startup()
-
-from OFS.Folder import Folder
-
-from common import BaseRegistryTests
-from common import DummyExportContext
-from common import DummyImportContext
-
-
-_EMPTY_EXPORT = """\
-<?xml version="1.0"?>
-<site>
-</site>
-"""
-
-_NORMAL_EXPORT = """\
-<?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>
-</site>
-"""
-
-
-class DummySite(Folder):
-
-    _properties = ()
-
-
-class _SitePropertiesSetup(BaseRegistryTests):
-
-    def _initSite(self, foo=2, bar=2):
-
-        self.root.site = DummySite()
-        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
-
-
-class SitePropertiesConfiguratorTests(_SitePropertiesSetup):
-
-    def _getTargetClass(self):
-
-        from Products.GenericSetup.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):
-
-        site = self._initSite(0, 0)
-        context = DummyExportContext(site)
-
-        from Products.GenericSetup.properties import exportSiteProperties
-        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):
-
-        site = self._initSite()
-        context = DummyExportContext( site )
-
-        from Products.GenericSetup.properties import exportSiteProperties
-        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):
-
-        site = self._initSite()
-
-        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',) )
-
-        context = DummyImportContext(site)
-        context._files['properties.xml'] = _EMPTY_EXPORT
-
-        from Products.GenericSetup.properties import importSiteProperties
-        importSiteProperties(context)
-
-        self.assertEqual( len( site.propertyIds() ), 0 )
-
-    def test_empty_explicit_purge(self):
-
-        site = self._initSite()
-
-        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',) )
-
-        context = DummyImportContext(site, True)
-        context._files['properties.xml'] = _EMPTY_EXPORT
-
-        from Products.GenericSetup.properties import importSiteProperties
-        importSiteProperties(context)
-
-        self.assertEqual( len( site.propertyIds() ), 0 )
-
-    def test_empty_skip_purge(self):
-
-        site = self._initSite()
-
-        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',) )
-
-        context = DummyImportContext(site, False)
-        context._files['properties.xml'] = _EMPTY_EXPORT
-
-        from Products.GenericSetup.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_normal(self):
-
-        site = self._initSite(0,0)
-
-        self.assertEqual( len( site.propertyIds() ), 0 )
-
-        context = DummyImportContext(site)
-        context._files['properties.xml'] = _NORMAL_EXPORT
-
-        from Products.GenericSetup.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_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.GenericSetup.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),
-        ))
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')



More information about the CMF-checkins mailing list