Commit 9854c85e authored by Romain Courteaud's avatar Romain Courteaud

Add a context object parameter for evaluating a tales expression.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8381 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 86394d7a
...@@ -132,19 +132,26 @@ class Getter(Method): ...@@ -132,19 +132,26 @@ class Getter(Method):
self._storage_id = storage_id self._storage_id = storage_id
self._is_tales_type = (property_type == 'tales') self._is_tales_type = (property_type == 'tales')
def __call__(self, instance, *args, **kw): def __call__(self, instance, object=None, *args, **kw):
if len(args) > 0: if len(args) > 0:
default = args[0] default = args[0]
else: else:
default = self._default default = self._default
value = getattr(aq_base(instance), self._storage_id, None) # No acquisition on properties # No acquisition on properties
value = getattr(aq_base(instance), self._storage_id, None)
if value is not None: if value is not None:
if self._is_tales_type and kw.get('evaluate', 1): if self._is_tales_type and kw.get('evaluate', 1):
return evaluateTales(instance, value) if object is not None:
return evaluateTales(object, value)
else:
return evaluateTales(instance, value)
else: else:
return value return value
if default is not None and self._is_tales_type and kw.get('evaluate', 1): if default is not None and self._is_tales_type and kw.get('evaluate', 1):
return evaluateTales(instance, default) if object is not None:
return evaluateTales(object, default)
else:
return evaluateTales(instance, default)
return default return default
psyco.bind(__call__) psyco.bind(__call__)
......
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