[Erp5-report] r43152 arnaud.fontaine - in /erp5/trunk/products/ERP5Type: ./ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Feb 8 04:20:27 CET 2011


Author: arnaud.fontaine
Date: Tue Feb  8 04:20:26 2011
New Revision: 43152

URL: http://svn.erp5.org?rev=43152&view=rev
Log:
Before r42902, getProperty() was getting the accessor method of the
property through the portal type property holder. r42902 introduced
portal type as classes and per property sheets accessor holders, but
incorrectly called the accessor method on the instance (thus could
possibly ending up calling the method of one of its parent through
acquisition) rather than the portal type class itself.

Add a test checking for such case. This commit fixes testXHTML.

Modified:
    erp5/trunk/products/ERP5Type/Base.py
    erp5/trunk/products/ERP5Type/tests/testERP5Type.py

Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=43152&r1=43151&r2=43152&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Base.py [utf8] Tue Feb  8 04:20:26 2011
@@ -1259,16 +1259,16 @@ class Base( CopyContainer,
     # and return it as a list
     if accessor_name.endswith('List'):
       mono_valued_accessor_name = accessor_name[:-4]
-      method = getattr(self, mono_valued_accessor_name, None)
+      method = getattr(self.__class__, mono_valued_accessor_name, None)
       if method is not None:
         # We have a monovalued property
         if d is _MARKER:
-          result = method(**kw)
+          result = method(self, **kw)
         else:
           try:
-            result = method(d, **kw)
+            result = method(self, d, **kw)
           except TypeError:
-            result = method(**kw)
+            result = method(self, **kw)
         if not isinstance(result, (list, tuple)):
           result = [result]
         return result

Modified: erp5/trunk/products/ERP5Type/tests/testERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testERP5Type.py?rev=43152&r1=43151&r2=43152&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testERP5Type.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testERP5Type.py [utf8] Tue Feb  8 04:20:26 2011
@@ -2859,6 +2859,27 @@ class TestERP5Type(PropertySheetTestCase
       person.setPropertyList('foo_bar', [])
       self.assertEquals(person.getFooBarList(), [])
 
+    def testPropertyNoAcquisition(self):
+      """
+      Check that getPropertyList (and getProperty as well as
+      getPropertyList calls getProperty) do not get the property
+      defined on its parent through acquisition
+      """
+      self._addProperty('Person Module',
+                        'testPropertyListWithMultivaluedPropertyNoAcquisition',
+                        'multivalued_no_acquisition',
+                        elementary_type='lines',
+                        portal_type='Standard Property')
+
+      person_module = self.getPersonModule()
+      person_module.setPropertyList('multivalued_no_acquisition', ['foo'])
+      self.assertEquals(
+        person_module.getPropertyList('multivalued_no_acquisition'), ['foo'])
+
+      person = self.getPersonModule().newContent(portal_type='Person')
+      self.assertEquals(
+        person.getPropertyList('multivalued_no_acquisition', ['bar']), ['bar'])
+
     def testUndefinedProperties(self):
       """
       Make sure that getProperty and setProperty on a property not defined



More information about the Erp5-report mailing list