[Erp5-report] r17703 - in /erp5/trunk/products/ERP5Type: Accessor/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Nov 20 13:30:56 CET 2007
Author: jerome
Date: Tue Nov 20 13:30:55 2007
New Revision: 17703
URL: http://svn.erp5.org?rev=17703&view=rev
Log:
Default getter for list property should not acquire the property (like any other getter)
Modified:
erp5/trunk/products/ERP5Type/Accessor/List.py
erp5/trunk/products/ERP5Type/tests/testERP5Type.py
Modified: erp5/trunk/products/ERP5Type/Accessor/List.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Accessor/List.py?rev=17703&r1=17702&r2=17703&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Accessor/List.py (original)
+++ erp5/trunk/products/ERP5Type/Accessor/List.py Tue Nov 20 13:30:55 2007
@@ -228,7 +228,7 @@
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):
Modified: erp5/trunk/products/ERP5Type/tests/testERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testERP5Type.py?rev=17703&r1=17702&r2=17703&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testERP5Type.py (original)
+++ erp5/trunk/products/ERP5Type/tests/testERP5Type.py Tue Nov 20 13:30:55 2007
@@ -1684,6 +1684,34 @@
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):
More information about the Erp5-report
mailing list