Commit 00a643ee authored by Arnaud Fontaine's avatar Arnaud Fontaine

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.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43152 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fcc06546
......@@ -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
......
......@@ -2859,6 +2859,27 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment