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,18 +132,25 @@ class Getter(Method):
self._storage_id = storage_id
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:
default = args[0]
else:
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 self._is_tales_type and kw.get('evaluate', 1):
if object is not None:
return evaluateTales(object, value)
else:
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 default
......
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