diff --git a/product/ERP5Type/Utils.py b/product/ERP5Type/Utils.py index 883593a0b1f652d5f1d38f3f905b5d1033a2c6c2..ce91b642046604155f3edde8547b700450afa8ad 100644 --- a/product/ERP5Type/Utils.py +++ b/product/ERP5Type/Utils.py @@ -60,6 +60,7 @@ from Products.ERP5Type import Permissions from Products.ERP5Type import Constraint from Products.ERP5Type.Cache import getReadOnlyTransactionCache +from Products.ERP5Type.TransactionalVariable import getTransactionalVariable from zLOG import LOG, BLATHER, PROBLEM, WARNING from AccessControl.SecurityManagement import newSecurityManager, getSecurityManager @@ -1134,6 +1135,12 @@ def createExpressionContext(object, portal=None): """ Return a context used for evaluating a TALES expression. """ + tv = getTransactionalVariable(None) + cache_key = ('createExpressionContext', id(object)) + try: + return tv[cache_key] + except KeyError: + pass if portal is None and object is not None: portal = object.getPortalObject() @@ -1187,7 +1194,9 @@ def createExpressionContext(object, portal=None): 'member': member, 'here': object, } - return getEngine().getContext(data) + ec = getEngine().getContext(data) + tv[cache_key] = ec + return ec def getExistingBaseCategoryList(portal, base_cat_list): cache = getReadOnlyTransactionCache(portal)