Commit 6b56fa54 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Re-implement read-only transaction cache in the term of a transactional variable.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13762 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 68921d17
...@@ -31,6 +31,7 @@ from time import time ...@@ -31,6 +31,7 @@ from time import time
from AccessControl.SecurityInfo import allow_class from AccessControl.SecurityInfo import allow_class
from CachePlugins.BaseCache import CachedMethodError from CachePlugins.BaseCache import CachedMethodError
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
DEFAULT_CACHE_SCOPE = 'GLOBAL' DEFAULT_CACHE_SCOPE = 'GLOBAL'
DEFAULT_CACHE_FACTORY = 'erp5_ui_short' DEFAULT_CACHE_FACTORY = 'erp5_ui_short'
...@@ -224,20 +225,26 @@ allow_class(CachingMethod) ...@@ -224,20 +225,26 @@ allow_class(CachingMethod)
def getReadOnlyTransactionCache(context): def getReadOnlyTransactionCache(context):
"""Get the transaction cache. """Get the transaction cache.
""" """
tv = getTransactionalVariable()
try: try:
return context.REQUEST['_erp5_read_only_transaction_cache'] return tv['read_only_transaction_cache']
except KeyError: except KeyError:
return None return None
def enableReadOnlyTransactionCache(context): def enableReadOnlyTransactionCache(context):
"""Enable the transaction cache. """Enable the transaction cache.
""" """
context.REQUEST.set('_erp5_read_only_transaction_cache', {}) tv = getTransactionalVariable()
tv['read_only_transaction_cache'] = {}
def disableReadOnlyTransactionCache(context): def disableReadOnlyTransactionCache(context):
"""Disable the transaction cache. """Disable the transaction cache.
""" """
context.REQUEST.set('_erp5_read_only_transaction_cache', None) tv = getTransactionalVariable()
try:
del tv['read_only_transaction_cache']
except KeyError:
pass
######################################################## ########################################################
## Old global cache functions ## ## Old global cache functions ##
......
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