[CMF-checkins] SVN: CMF/trunk/GenericSetup/ In extension profiles,
sequence properties are now extended instead of
Florent Guillaume
fg at nuxeo.com
Wed Jan 4 18:40:45 EST 2006
Log message for revision 41142:
In extension profiles, sequence properties are now extended instead of
replaced, except if the 'remove' attribute is present.
This can be used for instance by extension profiles to add values to the
'allowed_content_types' property of a TypeInformation object.
Changed:
U CMF/trunk/GenericSetup/CHANGES.txt
U CMF/trunk/GenericSetup/testing.py
U CMF/trunk/GenericSetup/tests/test_utils.py
U CMF/trunk/GenericSetup/utils.py
-=-
Modified: CMF/trunk/GenericSetup/CHANGES.txt
===================================================================
--- CMF/trunk/GenericSetup/CHANGES.txt 2006-01-04 23:23:41 UTC (rev 41141)
+++ CMF/trunk/GenericSetup/CHANGES.txt 2006-01-04 23:40:45 UTC (rev 41142)
@@ -11,6 +11,9 @@
- Forward ported changes from GenericSetup 0.11 and 0.12 (which were
created in a separate repository).
+ - In extension profiles, sequence properties are now extended
+ instead of replaced, except if the 'remove' attribute is present.
+
- Don't export or purge read-only properties. Correctly purge
non-deletable int/float properties.
Modified: CMF/trunk/GenericSetup/testing.py
===================================================================
--- CMF/trunk/GenericSetup/testing.py 2006-01-04 23:23:41 UTC (rev 41141)
+++ CMF/trunk/GenericSetup/testing.py 2006-01-04 23:40:45 UTC (rev 41142)
@@ -58,12 +58,13 @@
def __init__(self):
self._notes = []
+ self._should_purge = True
def getLogger(self, name):
return DummyLogger(name, self._notes)
def shouldPurge(self):
- return True
+ return self._should_purge
class _AdapterTestCaseBase(PlacelessSetup, unittest.TestCase):
Modified: CMF/trunk/GenericSetup/tests/test_utils.py
===================================================================
--- CMF/trunk/GenericSetup/tests/test_utils.py 2006-01-04 23:23:41 UTC (rev 41141)
+++ CMF/trunk/GenericSetup/tests/test_utils.py 2006-01-04 23:40:45 UTC (rev 41142)
@@ -119,7 +119,21 @@
</dummy>
"""
+_NOPURGE_IMPORT = """\
+<?xml version="1.0"?>
+<dummy>
+ <property name="lines1">
+ <element value="Foo"/>
+ <element value="Bar"/>
+ </property>
+ <property name="lines2" remove="True">
+ <element value="Foo"/>
+ <element value="Bar"/>
+ </property>
+</dummy>
+"""
+
def _testFunc( *args, **kw ):
""" This is a test.
@@ -321,7 +335,19 @@
self.assertEqual(doc.toprettyxml(' '), _EMPTY_PROPERTY_EXPORT)
+ def test__initProperties_nopurge(self):
+ node = parseString(_NOPURGE_IMPORT).documentElement
+ self.helpers.environ._should_purge = False
+ obj = self.helpers.context
+ obj._properties = ()
+ obj.manage_addProperty('lines1', ('A', 'B'), 'lines')
+ obj.manage_addProperty('lines2', ('A', 'B'), 'lines')
+ self.helpers._initProperties(node)
+ self.assertEquals(obj.lines1, ('A', 'B', 'Foo', 'Bar'))
+ self.assertEquals(obj.lines2, ('Foo', 'Bar'))
+
+
class PrettyDocumentTests(unittest.TestCase):
def test_attr_quoting(self):
Modified: CMF/trunk/GenericSetup/utils.py
===================================================================
--- CMF/trunk/GenericSetup/utils.py 2006-01-04 23:23:41 UTC (rev 41141)
+++ CMF/trunk/GenericSetup/utils.py 2006-01-04 23:40:45 UTC (rev 41142)
@@ -686,6 +686,13 @@
# are converted to the right type
prop_value = self._getNodeText(child).encode('utf-8')
+ if (not self.environ.shouldPurge()
+ and not child.hasAttribute('remove')):
+ # If not purge mode and no remove attribute, append to sequence
+ prop = obj.getProperty(prop_id)
+ if isinstance(prop, (tuple, list)):
+ prop_value = tuple(prop) + tuple(prop_value)
+
obj._updateProperty(prop_id, prop_value)
More information about the CMF-checkins
mailing list