[CMF-checkins] SVN: CMF/trunk/CMFSetup/ Allow export of old
instances of list properties (instead of tuples).
Florent Guillaume
fg at nuxeo.com
Thu Sep 8 13:43:57 EDT 2005
Log message for revision 38406:
Allow export of old instances of list properties (instead of tuples).
Changed:
U CMF/trunk/CMFSetup/tests/test_properties.py
U CMF/trunk/CMFSetup/utils.py
-=-
Modified: CMF/trunk/CMFSetup/tests/test_properties.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_properties.py 2005-09-08 15:36:00 UTC (rev 38405)
+++ CMF/trunk/CMFSetup/tests/test_properties.py 2005-09-08 17:43:57 UTC (rev 38406)
@@ -38,6 +38,8 @@
<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>
"""
@@ -61,8 +63,10 @@
if bar > 0:
site._setProperty( 'bar', (), 'tokens' )
+ site._setProperty( 'moo', (), 'tokens' )
if bar > 1:
site._updateProperty( 'bar', ('Bar',) )
+ site.moo = ['Moo']
return site
@@ -87,6 +91,11 @@
'value': '',
'elements': ('Bar',),
'type': 'tokens',
+ 'select_variable': None },
+ { 'id': 'moo',
+ 'value': '',
+ 'elements': ('Moo',),
+ 'type': 'tokens',
'select_variable': None } ]
configurator = self._makeOne(site)
@@ -125,7 +134,7 @@
configurator = self._makeOne(site)
site_info = configurator.parseXML(_NORMAL_EXPORT)
- self.assertEqual( len( site_info['properties'] ), 2 )
+ self.assertEqual( len( site_info['properties'] ), 3 )
info = site_info['properties'][0]
self.assertEqual( info['id'], 'foo' )
@@ -176,7 +185,7 @@
site = self._initSite()
- self.assertEqual( len( site.propertyIds() ), 2 )
+ self.assertEqual( len( site.propertyIds() ), 3 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
@@ -194,7 +203,7 @@
site = self._initSite()
- self.assertEqual( len( site.propertyIds() ), 2 )
+ self.assertEqual( len( site.propertyIds() ), 3 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
@@ -212,7 +221,7 @@
site = self._initSite()
- self.assertEqual( len( site.propertyIds() ), 2 )
+ self.assertEqual( len( site.propertyIds() ), 3 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
@@ -224,7 +233,7 @@
from Products.CMFSetup.properties import importSiteProperties
importSiteProperties(context)
- self.assertEqual( len( site.propertyIds() ), 2 )
+ self.assertEqual( len( site.propertyIds() ), 3 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
@@ -242,7 +251,7 @@
from Products.CMFSetup.properties import importSiteProperties
importSiteProperties(context)
- self.assertEqual( len( site.propertyIds() ), 2 )
+ self.assertEqual( len( site.propertyIds() ), 3 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
@@ -260,7 +269,7 @@
from Products.CMFSetup.properties import importSiteProperties
importSiteProperties(context)
- self.assertEqual( len( site.propertyIds() ), 2 )
+ self.assertEqual( len( site.propertyIds() ), 3 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
Modified: CMF/trunk/CMFSetup/utils.py
===================================================================
--- CMF/trunk/CMFSetup/utils.py 2005-09-08 15:36:00 UTC (rev 38405)
+++ CMF/trunk/CMFSetup/utils.py 2005-09-08 17:43:57 UTC (rev 38406)
@@ -386,6 +386,11 @@
if isinstance(prop, tuple):
prop_value = ''
prop_elements = prop
+ elif isinstance(prop, list):
+ # Backward compat for old instances that stored
+ # properties as list.
+ prop_value = ''
+ prop_elements = tuple(prop)
else:
prop_value = prop
prop_elements = ()
More information about the CMF-checkins
mailing list