From d0ef2af0a69186fd7ef46bf5d4b72b0b4d1b267d Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine <arnaud.fontaine@nexedi.com> Date: Wed, 2 Mar 2011 16:54:35 +0000 Subject: [PATCH] expression_context must not be a global variable but a transactional variable, otherwise it is kept for further transactions, thus leading to ZODB ConnectionStateError. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43910 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/dynamic/accessor_holder.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/product/ERP5Type/dynamic/accessor_holder.py b/product/ERP5Type/dynamic/accessor_holder.py index 9a80ef6b9e..db81d4424f 100644 --- a/product/ERP5Type/dynamic/accessor_holder.py +++ b/product/ERP5Type/dynamic/accessor_holder.py @@ -38,6 +38,7 @@ from types import ModuleType from Products.ERP5Type import Permissions from Products.ERP5Type.Utils import createExpressionContext from Products.ERP5Type.Globals import InitializeClass +from Products.ERP5Type.TransactionalVariable import getTransactionalVariable from Products.ERP5Type.Utils import UpperCase from Products.ERP5Type.Accessor import Related, RelatedValue @@ -298,13 +299,11 @@ def getPropertySheetValueList(site, property_sheet_name_set): return property_sheet_value_list -expression_context = None - def getAccessorHolderList(site, portal_type_name, property_sheet_value_list): import erp5.accessor_holder - global expression_context accessor_holder_list = [] + tv = getTransactionalVariable() for property_sheet in property_sheet_value_list: # LOG("ERP5Type.dynamic", INFO, @@ -323,8 +322,11 @@ def getAccessorHolderList(site, portal_type_name, property_sheet_value_list): property_sheet_name)) except AttributeError: # lazily create the context, only if needed. - if expression_context is None: + try: + expression_context = tv['accessor_holder_expression_context'] + except KeyError: expression_context = createExpressionContext(site) + tv['accessor_holder_expression_context'] = expression_context # Generate the accessor holder as it has not been done yet accessor_holder_class = property_sheet.createAccessorHolder( -- 2.30.9