From 55392f35f2a9755bf7d41cf0353558cb246f52bc Mon Sep 17 00:00:00 2001 From: Kazuhiko Shiozaki <kazuhiko@nexedi.com> Date: Fri, 16 Oct 2009 14:33:11 +0000 Subject: [PATCH] use transactional cache for createExpressionContext value just same as Expression.getExprContext does. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29771 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/product/ERP5Type/Utils.py b/product/ERP5Type/Utils.py index 883593a0b1..ce91b64204 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) -- 2.30.9