Commit 22cee6c5 authored by Julien Muchembled's avatar Julien Muchembled

Deprecate passing a parameter to getTransactionalVariable

getTransactionalVariable has always been implemented to return a global
cache object (1 per thread): old implementation used the given context only to
have access to the portal.

So we enforce this with a warning to make sure people don't expect retrieving
1 cache object per given context.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38366 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5f2181bc
...@@ -98,7 +98,7 @@ class ActiveObject(ExtensionClass.Base): ...@@ -98,7 +98,7 @@ class ActiveObject(ExtensionClass.Base):
kw[k] = v kw[k] = v
# Get default parameters from a transactional variable. # Get default parameters from a transactional variable.
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
key = ('default_activate_parameter', id(aq_base(self))) key = ('default_activate_parameter', id(aq_base(self)))
try: try:
for k, v in tv[key].iteritems(): for k, v in tv[key].iteritems():
...@@ -173,14 +173,14 @@ class ActiveObject(ExtensionClass.Base): ...@@ -173,14 +173,14 @@ class ActiveObject(ExtensionClass.Base):
# This method sets the default keyword parameters to activate. This is # This method sets the default keyword parameters to activate. This is
# useful when you need to specify special parameters implicitly (e.g. to # useful when you need to specify special parameters implicitly (e.g. to
# reindexObject). # reindexObject).
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
key = ('default_activate_parameter', id(aq_base(self))) key = ('default_activate_parameter', id(aq_base(self)))
tv[key] = kw tv[key] = kw
def getDefaultActivateParameterDict(self, inherit_placeless=True): def getDefaultActivateParameterDict(self, inherit_placeless=True):
# This method returns default activate parameters to self. # This method returns default activate parameters to self.
# The result can be either a dict object or None. # The result can be either a dict object or None.
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
if inherit_placeless: if inherit_placeless:
placeless = tv.get(('default_activate_parameter', )) placeless = tv.get(('default_activate_parameter', ))
if placeless is not None: if placeless is not None:
......
...@@ -322,7 +322,7 @@ class SQLBase: ...@@ -322,7 +322,7 @@ class SQLBase:
# So all connectors must be committed now that we have selected # So all connectors must be committed now that we have selected
# everything needed from MySQL to get a fresh view of ZODB objects. # everything needed from MySQL to get a fresh view of ZODB objects.
transaction.commit() transaction.commit()
tv = getTransactionalVariable(None) tv = getTransactionalVariable()
tv['activity_runtime_environment'] = activity_runtime_environment tv['activity_runtime_environment'] = activity_runtime_environment
# Try to invoke # Try to invoke
try: try:
......
...@@ -4,7 +4,7 @@ def getActivityRuntimeEnvironment(): ...@@ -4,7 +4,7 @@ def getActivityRuntimeEnvironment():
""" """
Raises KeyError if called outside activity. Raises KeyError if called outside activity.
""" """
return getTransactionalVariable(None)['activity_runtime_environment'] return getTransactionalVariable()['activity_runtime_environment']
def _getActivityRuntimeEnvironment(): def _getActivityRuntimeEnvironment():
try: try:
......
...@@ -421,7 +421,7 @@ class Amount(Base, Variated): ...@@ -421,7 +421,7 @@ class Amount(Base, Variated):
# Stop any recursive call to this method. This happens when a Path # Stop any recursive call to this method. This happens when a Path
# does not have base unit price locally, so it looks it up, and # does not have base unit price locally, so it looks it up, and
# each path of a predicate list does the same again. # each path of a predicate list does the same again.
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
key = '_getBaseUnitPrice' key = '_getBaseUnitPrice'
if key in tv: if key in tv:
return return
......
...@@ -98,7 +98,7 @@ class AppliedRule(XMLObject): ...@@ -98,7 +98,7 @@ class AppliedRule(XMLObject):
An applied rule can be expanded only if its parent movement An applied rule can be expanded only if its parent movement
is expanded. is expanded.
""" """
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
cache = tv.setdefault(TREE_DELIVERED_CACHE_KEY, {}) cache = tv.setdefault(TREE_DELIVERED_CACHE_KEY, {})
cache_enabled = cache.get(TREE_DELIVERED_CACHE_ENABLED, 0) cache_enabled = cache.get(TREE_DELIVERED_CACHE_ENABLED, 0)
...@@ -247,7 +247,7 @@ class AppliedRule(XMLObject): ...@@ -247,7 +247,7 @@ class AppliedRule(XMLObject):
see SimulationMovement._isTreeDelivered see SimulationMovement._isTreeDelivered
""" """
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
cache = tv.setdefault(TREE_DELIVERED_CACHE_KEY, {}) cache = tv.setdefault(TREE_DELIVERED_CACHE_KEY, {})
cache_enabled = cache.get(TREE_DELIVERED_CACHE_ENABLED, 0) cache_enabled = cache.get(TREE_DELIVERED_CACHE_ENABLED, 0)
......
...@@ -762,16 +762,16 @@ class BPMBuilder(Alarm): ...@@ -762,16 +762,16 @@ class BPMBuilder(Alarm):
return obj return obj
def _isUpdated(self, obj, level): def _isUpdated(self, obj, level):
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
return level in tv['builder_processed_list'].get(obj, []) return level in tv['builder_processed_list'].get(obj, [])
def _setUpdated(self, obj, level): def _setUpdated(self, obj, level):
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
if tv.get('builder_processed_list', None) is None: if tv.get('builder_processed_list', None) is None:
self._resetUpdated() self._resetUpdated()
tv['builder_processed_list'][obj] = \ tv['builder_processed_list'][obj] = \
tv['builder_processed_list'].get(obj, []) + [level] tv['builder_processed_list'].get(obj, []) + [level]
def _resetUpdated(self): def _resetUpdated(self):
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
tv['builder_processed_list'] = {} tv['builder_processed_list'] = {}
...@@ -357,7 +357,7 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixIn, CachedCo ...@@ -357,7 +357,7 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixIn, CachedCo
NOTE: passing a group_by parameter may be useful at a NOTE: passing a group_by parameter may be useful at a
later stage of the implementation. later stage of the implementation.
""" """
tv = getTransactionalVariable(self) # XXX Performance improvement required tv = getTransactionalVariable() # XXX Performance improvement required
cache_key = ('getImplicitSuccessorValueList', self.getPhysicalPath()) cache_key = ('getImplicitSuccessorValueList', self.getPhysicalPath())
try: try:
return tv[cache_key] return tv[cache_key]
......
...@@ -231,7 +231,7 @@ class SimulationMovement(Movement, PropertyRecordableMixin): ...@@ -231,7 +231,7 @@ class SimulationMovement(Movement, PropertyRecordableMixin):
""" """
portal_rules = getToolByName(self.getPortalObject(), 'portal_rules') portal_rules = getToolByName(self.getPortalObject(), 'portal_rules')
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
cache = tv.setdefault(TREE_DELIVERED_CACHE_KEY, {}) cache = tv.setdefault(TREE_DELIVERED_CACHE_KEY, {})
cache_enabled = cache.get(TREE_DELIVERED_CACHE_ENABLED, 0) cache_enabled = cache.get(TREE_DELIVERED_CACHE_ENABLED, 0)
...@@ -520,7 +520,7 @@ class SimulationMovement(Movement, PropertyRecordableMixin): ...@@ -520,7 +520,7 @@ class SimulationMovement(Movement, PropertyRecordableMixin):
see AppliedRule._isTreeDelivered see AppliedRule._isTreeDelivered
""" """
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
cache = tv.setdefault(TREE_DELIVERED_CACHE_KEY, {}) cache = tv.setdefault(TREE_DELIVERED_CACHE_KEY, {})
cache_enabled = cache.get(TREE_DELIVERED_CACHE_ENABLED, 0) cache_enabled = cache.get(TREE_DELIVERED_CACHE_ENABLED, 0)
......
...@@ -1278,7 +1278,7 @@ class ERP5Site(FolderMixIn, CMFSite): ...@@ -1278,7 +1278,7 @@ class ERP5Site(FolderMixIn, CMFSite):
# This method sets the default keyword parameters to reindex. This is useful # This method sets the default keyword parameters to reindex. This is useful
# when you need to specify special parameters implicitly (e.g. to reindexObject). # when you need to specify special parameters implicitly (e.g. to reindexObject).
# Those parameters will affect all reindex calls, not just ones on self. # Those parameters will affect all reindex calls, not just ones on self.
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
key = ('default_reindex_parameter', ) key = ('default_reindex_parameter', )
tv[key] = kw tv[key] = kw
...@@ -1287,7 +1287,7 @@ class ERP5Site(FolderMixIn, CMFSite): ...@@ -1287,7 +1287,7 @@ class ERP5Site(FolderMixIn, CMFSite):
# This method sets the default keyword parameters to activate. This is useful # This method sets the default keyword parameters to activate. This is useful
# when you need to specify special parameters implicitly (e.g. to reindexObject). # when you need to specify special parameters implicitly (e.g. to reindexObject).
# Those parameters will affect all activate calls, not just ones on self. # Those parameters will affect all activate calls, not just ones on self.
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
key = ('default_activate_parameter', ) key = ('default_activate_parameter', )
tv[key] = kw tv[key] = kw
...@@ -1295,7 +1295,7 @@ class ERP5Site(FolderMixIn, CMFSite): ...@@ -1295,7 +1295,7 @@ class ERP5Site(FolderMixIn, CMFSite):
def getPlacelessDefaultReindexParameters(self): def getPlacelessDefaultReindexParameters(self):
# This method returns default reindex parameters to self. # This method returns default reindex parameters to self.
# The result can be either a dict object or None. # The result can be either a dict object or None.
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
key = ('default_reindex_parameter', ) key = ('default_reindex_parameter', )
return tv.get(key) return tv.get(key)
...@@ -1303,7 +1303,7 @@ class ERP5Site(FolderMixIn, CMFSite): ...@@ -1303,7 +1303,7 @@ class ERP5Site(FolderMixIn, CMFSite):
def getPlacelessDefaultActivateParameters(self): def getPlacelessDefaultActivateParameters(self):
# This method returns default activate parameters to self. # This method returns default activate parameters to self.
# The result can be either a dict object or None. # The result can be either a dict object or None.
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
key = ('default_activate_parameter', ) key = ('default_activate_parameter', )
return tv.get(key) return tv.get(key)
......
...@@ -157,7 +157,7 @@ class CachedConvertableMixin: ...@@ -157,7 +157,7 @@ class CachedConvertableMixin:
cache_duration = cache_factory.cache_duration cache_duration = cache_factory.cache_duration
# The purpose of this transaction cache is to help calls # The purpose of this transaction cache is to help calls
# to the same cache value in the same transaction. # to the same cache value in the same transaction.
tv = getTransactionalVariable(None) tv = getTransactionalVariable()
tv[cache_id] = stored_data_dict tv[cache_id] = stored_data_dict
for cache_plugin in cache_factory.getCachePluginList(): for cache_plugin in cache_factory.getCachePluginList():
cache_plugin.set(cache_id, DEFAULT_CACHE_SCOPE, cache_plugin.set(cache_id, DEFAULT_CACHE_SCOPE,
...@@ -172,7 +172,7 @@ class CachedConvertableMixin: ...@@ -172,7 +172,7 @@ class CachedConvertableMixin:
return getattr(aq_base(self), 'temp_conversion_data', {})[cache_id] return getattr(aq_base(self), 'temp_conversion_data', {})[cache_id]
# The purpose of this cache is to help calls to the same cache value # The purpose of this cache is to help calls to the same cache value
# in the same transaction. # in the same transaction.
tv = getTransactionalVariable(None) tv = getTransactionalVariable()
try: try:
return tv[cache_id] return tv[cache_id]
except KeyError: except KeyError:
......
...@@ -61,7 +61,7 @@ class DocumentMixin: ...@@ -61,7 +61,7 @@ class DocumentMixin:
string (ex. jpeg, html, text, txt, etc.) string (ex. jpeg, html, text, txt, etc.)
**kw can be various things - e.g. resolution **kw can be various things - e.g. resolution
""" """
transaction_variable = getTransactionalVariable(self.getPortalObject()) transaction_variable = getTransactionalVariable()
if LOCK_PERMISSION_KEY in transaction_variable: if LOCK_PERMISSION_KEY in transaction_variable:
# in convert we want always to check conversion format permission # in convert we want always to check conversion format permission
# to bypass such check one should use _convert directly # to bypass such check one should use _convert directly
...@@ -95,7 +95,7 @@ class DocumentMixin: ...@@ -95,7 +95,7 @@ class DocumentMixin:
"""Private method to check permission when access specified format. """Private method to check permission when access specified format.
This method raises This method raises
""" """
transaction_variable = getTransactionalVariable(self.getPortalObject()) transaction_variable = getTransactionalVariable()
if transaction_variable.get(LOCK_PERMISSION_KEY, False): if transaction_variable.get(LOCK_PERMISSION_KEY, False):
# Permission already checked in convert with final format, # Permission already checked in convert with final format,
# do not check permission for intermediate formats # do not check permission for intermediate formats
......
...@@ -546,7 +546,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -546,7 +546,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
if allowedRolesAndUsers: if allowedRolesAndUsers:
allowedRolesAndUsers.sort() allowedRolesAndUsers.sort()
cache_key = tuple(allowedRolesAndUsers) cache_key = tuple(allowedRolesAndUsers)
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
try: try:
security_uid_cache = tv['getSecurityUidListAndRoleColumnDict'] security_uid_cache = tv['getSecurityUidListAndRoleColumnDict']
except KeyError: except KeyError:
......
...@@ -226,7 +226,7 @@ class PreferenceTool(BaseTool): ...@@ -226,7 +226,7 @@ class PreferenceTool(BaseTool):
""" return the most appropriate preferences objects, """ return the most appropriate preferences objects,
sorted so that the first in the list should be applied first sorted so that the first in the list should be applied first
""" """
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
user = getToolByName(self, 'portal_membership').getAuthenticatedMember() user = getToolByName(self, 'portal_membership').getAuthenticatedMember()
tv_key = 'PreferenceTool._getSortedPreferenceList/%s/%s' % (user, tv_key = 'PreferenceTool._getSortedPreferenceList/%s/%s' % (user,
sql_catalog_id) sql_catalog_id)
......
...@@ -760,12 +760,12 @@ class ProxyField(ZMIField): ...@@ -760,12 +760,12 @@ class ProxyField(ZMIField):
return '%s%s' % ('ProxyField', self._p_oid or repr(self)) return '%s%s' % ('ProxyField', self._p_oid or repr(self))
def _setTemplateFieldCache(self, field): def _setTemplateFieldCache(self, field):
getTransactionalVariable(self)[self._getCacheId()] = field getTransactionalVariable()[self._getCacheId()] = field
def _getTemplateFieldCache(self): def _getTemplateFieldCache(self):
parent = self.aq_parent parent = self.aq_parent
if parent is not None: if parent is not None:
cache = getTransactionalVariable(self)[self._getCacheId()] cache = getTransactionalVariable()[self._getCacheId()]
if cache is not None: if cache is not None:
return cache.__of__(parent) return cache.__of__(parent)
raise KeyError raise KeyError
......
...@@ -1382,7 +1382,7 @@ class SelectionTool( BaseTool, SimpleItem ): ...@@ -1382,7 +1382,7 @@ class SelectionTool( BaseTool, SimpleItem ):
return SelectionTool.inheritedAttribute('_aq_dynamic')(self, name) return SelectionTool.inheritedAttribute('_aq_dynamic')(self, name)
def _getUserId(self): def _getUserId(self):
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
user_id = tv.get('_user_id', None) user_id = tv.get('_user_id', None)
if user_id is not None: if user_id is not None:
return user_id return user_id
...@@ -1400,7 +1400,7 @@ class SelectionTool( BaseTool, SimpleItem ): ...@@ -1400,7 +1400,7 @@ class SelectionTool( BaseTool, SimpleItem ):
""" Temporary selections are used in push/pop nested scope, """ Temporary selections are used in push/pop nested scope,
to prevent from editting for stored selection in the scope. to prevent from editting for stored selection in the scope.
Typically, it is used for ReportSection.""" Typically, it is used for ReportSection."""
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
return tv.setdefault('_temporary_selection_dict', {}) return tv.setdefault('_temporary_selection_dict', {})
def pushSelection(self, selection_name): def pushSelection(self, selection_name):
......
...@@ -178,7 +178,7 @@ class WorkflowMethod(Method): ...@@ -178,7 +178,7 @@ class WorkflowMethod(Method):
# Build a list of transitions which may need to be invoked # Build a list of transitions which may need to be invoked
instance_path = instance.getPhysicalPath() instance_path = instance.getPhysicalPath()
portal_type = instance.portal_type portal_type = instance.portal_type
transactional_variable = getTransactionalVariable(instance) transactional_variable = getTransactionalVariable()
invoke_once_item_list = self._invoke_once.get(portal_type, {}).items() invoke_once_item_list = self._invoke_once.get(portal_type, {}).items()
valid_invoke_once_item_list = [] valid_invoke_once_item_list = []
# Only keep those transitions which were never invoked # Only keep those transitions which were never invoked
...@@ -1086,7 +1086,7 @@ class Base( CopyContainer, ...@@ -1086,7 +1086,7 @@ class Base( CopyContainer,
going to edit the related object going to edit the related object
""" """
# Push context to prevent loop # Push context to prevent loop
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
if isinstance(portal_type, list): if isinstance(portal_type, list):
portal_type = tuple(portal_type) portal_type = tuple(portal_type)
acquisition_key = ('_getDefaultAcquiredProperty', self.getPath(), key, acquisition_key = ('_getDefaultAcquiredProperty', self.getPath(), key,
...@@ -1265,7 +1265,7 @@ class Base( CopyContainer, ...@@ -1265,7 +1265,7 @@ class Base( CopyContainer,
""" """
# Push context to prevent loop # Push context to prevent loop
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
if isinstance(portal_type, list): if isinstance(portal_type, list):
portal_type = tuple(portal_type) portal_type = tuple(portal_type)
acquisition_key = ('_getAcquiredPropertyList', self.getPath(), key, base_category, acquisition_key = ('_getAcquiredPropertyList', self.getPath(), key, base_category,
...@@ -3110,7 +3110,7 @@ class Base( CopyContainer, ...@@ -3110,7 +3110,7 @@ class Base( CopyContainer,
# use a transactional variable to cache results within the same # use a transactional variable to cache results within the same
# transaction # transaction
portal_type = self.getPortalType() portal_type = self.getPortalType()
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
type_base_cache = tv.setdefault('Base.type_based_cache', {}) type_base_cache = tv.setdefault('Base.type_based_cache', {})
cache_key = (portal_type, method_id) cache_key = (portal_type, method_id)
...@@ -3811,7 +3811,7 @@ class Base( CopyContainer, ...@@ -3811,7 +3811,7 @@ class Base( CopyContainer,
def setDefaultReindexParameters(self, **kw): def setDefaultReindexParameters(self, **kw):
# This method sets the default keyword parameters to reindex. This is useful # This method sets the default keyword parameters to reindex. This is useful
# when you need to specify special parameters implicitly (e.g. to reindexObject). # when you need to specify special parameters implicitly (e.g. to reindexObject).
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
key = ('default_reindex_parameter', id(aq_base(self))) key = ('default_reindex_parameter', id(aq_base(self)))
tv[key] = kw tv[key] = kw
...@@ -3820,7 +3820,7 @@ class Base( CopyContainer, ...@@ -3820,7 +3820,7 @@ class Base( CopyContainer,
def getDefaultReindexParameterDict(self, inherit_placeless=True): def getDefaultReindexParameterDict(self, inherit_placeless=True):
# This method returns default reindex parameters to self. # This method returns default reindex parameters to self.
# The result can be either a dict object or None. # The result can be either a dict object or None.
tv = getTransactionalVariable(self) tv = getTransactionalVariable()
if inherit_placeless: if inherit_placeless:
placeless = tv.get(('default_reindex_parameter', )) placeless = tv.get(('default_reindex_parameter', ))
if placeless is not None: if placeless is not None:
......
...@@ -299,7 +299,7 @@ def transactional_cached(key_method=lambda *args: args): ...@@ -299,7 +299,7 @@ def transactional_cached(key_method=lambda *args: args):
def decorator(function): def decorator(function):
key = repr(function) key = repr(function)
def wrapper(*args, **kw): def wrapper(*args, **kw):
cache = getTransactionalVariable(None).setdefault(key, {}) cache = getTransactionalVariable().setdefault(key, {})
subkey = key_method(*args, **kw) subkey = key_method(*args, **kw)
try: try:
return cache[subkey] return cache[subkey]
......
...@@ -55,6 +55,7 @@ Example:: ...@@ -55,6 +55,7 @@ Example::
toto = tv['toto'] = getToto() toto = tv['toto'] = getToto()
""" """
import warnings
from UserDict import IterableUserDict from UserDict import IterableUserDict
from Shared.DC.ZRDB.TM import TM from Shared.DC.ZRDB.TM import TM
from threading import local from threading import local
...@@ -83,8 +84,13 @@ class TransactionalVariable(TM, IterableUserDict): ...@@ -83,8 +84,13 @@ class TransactionalVariable(TM, IterableUserDict):
transactional_variable_pool = local() transactional_variable_pool = local()
def getTransactionalVariable(context): _MARKER = object()
def getTransactionalVariable(context=_MARKER):
"""Return a transactional variable.""" """Return a transactional variable."""
if context is not _MARKER:
warnings.warn("Passing a parameter to getTransactionalVariable() is"
" deprecated and will not be tolerated in the future",
DeprecationWarning)
try: try:
return transactional_variable_pool.instance return transactional_variable_pool.instance
except AttributeError: except AttributeError:
......
...@@ -1243,7 +1243,7 @@ def createExpressionContext(object, portal=None): ...@@ -1243,7 +1243,7 @@ def createExpressionContext(object, portal=None):
""" """
Return a context used for evaluating a TALES expression. Return a context used for evaluating a TALES expression.
""" """
tv = getTransactionalVariable(None) tv = getTransactionalVariable()
cache_key = ('createExpressionContext', id(object)) cache_key = ('createExpressionContext', id(object))
try: try:
return tv[cache_key] return tv[cache_key]
...@@ -1313,7 +1313,7 @@ def getExistingBaseCategoryList(portal, base_cat_list): ...@@ -1313,7 +1313,7 @@ def getExistingBaseCategoryList(portal, base_cat_list):
cache = getReadOnlyTransactionCache(portal) cache = getReadOnlyTransactionCache(portal)
if cache is None: if cache is None:
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
cache = getTransactionalVariable(portal) cache = getTransactionalVariable()
category_tool = portal.portal_categories category_tool = portal.portal_categories
new_base_cat_list = [] new_base_cat_list = []
for base_cat in base_cat_list: for base_cat in base_cat_list:
......
...@@ -55,7 +55,7 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor): ...@@ -55,7 +55,7 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
def test_01_DictInterface(self): def test_01_DictInterface(self):
"""Check if a transaction variable behaves in the same way as a dict. """ """Check if a transaction variable behaves in the same way as a dict. """
tv = getTransactionalVariable(self.portal) tv = getTransactionalVariable()
self.failIfEqual(tv, None) self.failIfEqual(tv, None)
# Test frequently used dict methods. This does not cover everything, # Test frequently used dict methods. This does not cover everything,
...@@ -82,7 +82,7 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor): ...@@ -82,7 +82,7 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
"""Check if a transaction variable does not persist over multiple """Check if a transaction variable does not persist over multiple
transactions. transactions.
""" """
tv = getTransactionalVariable(self.portal) tv = getTransactionalVariable()
self.failIfEqual(tv, None) self.failIfEqual(tv, None)
tv.clear() tv.clear()
...@@ -104,7 +104,7 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor): ...@@ -104,7 +104,7 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
"""Check if a transaction variable does not disappear within the same """Check if a transaction variable does not disappear within the same
transaction. transaction.
""" """
tv = getTransactionalVariable(self.portal) tv = getTransactionalVariable()
self.failIfEqual(tv, None) self.failIfEqual(tv, None)
tv.clear() tv.clear()
......
...@@ -98,7 +98,7 @@ try: ...@@ -98,7 +98,7 @@ try:
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
except ImportError: except ImportError:
LOG('SQLCatalog', WARNING, 'Count not import getTransactionalVariable, expect slowness.') LOG('SQLCatalog', WARNING, 'Count not import getTransactionalVariable, expect slowness.')
def getTransactionalVariable(context): def getTransactionalVariable():
return {} return {}
class transactional_cache_decorator: class transactional_cache_decorator:
...@@ -111,7 +111,7 @@ class transactional_cache_decorator: ...@@ -111,7 +111,7 @@ class transactional_cache_decorator:
def __call__(self, method): def __call__(self, method):
def wrapper(wrapped_self): def wrapper(wrapped_self):
transactional_cache = getTransactionalVariable(None) transactional_cache = getTransactionalVariable()
cache_id = self.cache_id cache_id = self.cache_id
try: try:
result = transactional_cache[cache_id] result = transactional_cache[cache_id]
......
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