Commit cba54878 authored by Jérome Perrin's avatar Jérome Perrin

Default getter for list property should not acquire the property (like any other getter)



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17703 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 066e492a
......@@ -228,7 +228,7 @@ class DefaultGetter(Method):
default = args[0]
else:
default = self._default
list_value = getattr(instance, self._storage_id, default)
list_value = getattr(aq_base(instance), self._storage_id, default)
if list_value is not None:
if self._is_tales_type:
if kw.get('evaluate', 1):
......
......@@ -1684,6 +1684,34 @@ class TestPropertySheet:
checked_permission=checked_permission)
self.assertSameSet([beta_path, gamma_path], foo.getRegionList())
def test_list_accessors(self):
self._addProperty('Person', '''{'id': 'dummy',
'type': 'lines',
'mode': 'w',}''')
module = self.getPersonModule()
# we set the property on the module, to check acquisition works as
# expected.
module.dummy = 'value acquired on the module'
person = module.newContent(id='1', portal_type='Person')
# default accessor and list accessors are generated
self.assertTrue(hasattr(person, 'getDummy'))
self.assertTrue(hasattr(person, 'getDummyList'))
self.assertEquals(person.getDummy(), None)
# self.assertEquals(person.getDummyList(), []) # XXX what is the default
# value for a list getter ?
person.setDummyList(['a', 'b'])
self.assertEquals(person.getDummy(), 'a')
self.assertEquals(person.getDummyList(), ['a', 'b'])
person.setDummy('value')
self.assertEquals(person.getDummy(), 'value')
self.assertEquals(person.getDummyList(), ['value'])
# _aq_reset should be called implicitly when the system configuration
# changes:
def test_aq_reset_on_portal_types_properties_change(self):
......
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