Commit f95a6e63 authored by Alexandre Boeglin's avatar Alexandre Boeglin

* revert Accessor/Base.py to a revision consistent with other accesors (6289)

* test_15 of testERP5Type now really uses the static getFirstName method


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10279 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 81e9c352
......@@ -35,8 +35,6 @@ from zLOG import LOG
from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type.PsycoWrapper import psyco
_MARKER=[]
# Creation of default constructor
class func_code: pass
......@@ -134,24 +132,19 @@ class Getter(Method):
self._storage_id = storage_id
self._is_tales_type = (property_type == 'tales')
def __call__(self, instance, default=_MARKER, object=None, *args, **kw):
if default is _MARKER:
def __call__(self, instance, *args, **kw):
if len(args) > 0:
default = args[0]
else:
default = self._default
# No acquisition on properties
value = getattr(aq_base(instance), self._storage_id, None)
value = getattr(aq_base(instance), self._storage_id, None) # No acquisition on properties
if value is not None:
if self._is_tales_type and kw.get('evaluate', 1):
if object is not None:
return evaluateTales(object, value)
else:
return evaluateTales(instance, value)
return evaluateTales(instance, value)
else:
return value
if default is not None and self._is_tales_type and kw.get('evaluate', 1):
if object is not None:
return evaluateTales(object, default)
else:
return evaluateTales(instance, default)
return evaluateTales(instance, default)
return default
psyco.bind(__call__)
......
......@@ -749,13 +749,11 @@ class TestPropertySheet:
module = self.getPersonModule()
person = module.newContent(id='1', portal_type='Person')
def getFirstName(object, default=None):
def getFirstName(default=None):
"dummy method to check default is passed correctly"
print (object, default)
return default
from Products.ERP5.Document.Person import Person
Person.getFirstName = getFirstName
person.getFirstName = getFirstName
# test static method
self.assertEquals(person.getFirstName(), None)
......@@ -764,7 +762,7 @@ class TestPropertySheet:
# test dynamic method
self.assertEquals(person.getLastName(), None)
self.assertEquals(person.getLastName('foo'), 'foo')
self.assertEquals(person.getLastName(default='foo'), 'foo')
#self.assertEquals(person.getLastName(default='foo'), 'foo')
# test static method through getProperty
self.assertEquals(person.getProperty('first_name'), None)
self.assertEquals(person.getProperty('first_name', 'foo'), 'foo')
......
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