Commit 8e7bd677 authored by Sebastien Robin's avatar Sebastien Robin

getProperty('foo', d='bar') was raising attribute error if

in the past a local property 'foo' was created, then deleted
(so with _local_properties still having information about the
removed property)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45131 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7cf277b5
......@@ -68,7 +68,7 @@ def PropertyManager_getProperty(self, id, d=None, evaluate=1,
econtext = createExpressionContext(self)
return expression(econtext)
elif property_type:
return getattr(self, id)
return getattr(self, id, d)
return d
def PropertyManager_getPropertyType(self, id, local_properties=False):
......
......@@ -66,7 +66,8 @@ class PropertySheetTestCase(ERP5TypeTestCase):
"""Clean up """
ttool = self.getTypesTool()
# remove all property sheet we added to type informations
for ti_name, psheet_list in self._added_property_sheets.items():
for ti_name, psheet_list in getattr(self, '_added_property_sheets',
{}).items():
ti = ttool.getTypeInfo(ti_name)
property_sheet_set = set(ti.getTypePropertySheetList())
for psheet in psheet_list:
......@@ -136,6 +137,8 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
def beforeTearDown(self):
transaction.abort()
# THIS IS UGLY, WE MUST REMOVE AS SOON AS POSSIBLE, NOT COMPATIBLE
# WITH LIVE TEST
for module in [ self.getPersonModule(),
self.getOrganisationModule(),
self.getCategoryTool().region ]:
......@@ -3075,6 +3078,15 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
property_id_dict[property_id] = 1
self.assertEqual([], non_unique_property_id_list)
def testLocalProperties(self):
portal = self.getPortalObject()
person = portal.person_module.newContent(portal_type='Person')
person.edit(foo_property='bar')
self.assertEquals('bar', person.getProperty('foo_property'))
del person.__dict__['foo_property']
self.assertEquals(None, person.getProperty('foo_property'))
self.assertEquals(None, person.getProperty('foobar_property'))
class TestAccessControl(ERP5TypeTestCase):
# Isolate test in a dedicaced class in order not to break other tests
# when this one fails.
......
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