Commit 0c418b24 authored by Alexandre Boeglin's avatar Alexandre Boeglin

Added possibility to use tales in property sheets, which get generated for

each object.

example :
    _properties = (
        {   'id'          : 'magic_id',
            'description' : 'Magic ID',
            'type'        : 'tales',
            'default'     : 'python: "12345_%s" % object.getId()',
            'mode'        : 'w' },
    )

with this example, getMagicId() will return a string composed of
'12345_' and the id of the current object.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4342 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 50583db5
......@@ -97,7 +97,9 @@ class Setter(Method):
# if the property value has changed
# to decide reindexing, like edit() ?
from Products.CMFCore.Expression import Expression
def _evaluateTales(instance=None, value=None):
from Products.ERP5Type.Utils import createExpressionContext
expression = Expression(value)
econtext = createExpressionContext(instance)
return expression(econtext)
......@@ -141,6 +143,8 @@ class Getter(Method):
return evaluateTales(instance, value)
else:
return value
if default is not None and self._is_tales_type and kw.get('evaluate', 1):
return evaluateTales(instance, default)
return default
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