Commit bae67752 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Rename TransactionCache to ReadOnlyTransactionCache, because several people...

Rename TransactionCache to ReadOnlyTransactionCache, because several people misunderstood the purpose.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6164 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9a9476a2
...@@ -37,7 +37,7 @@ from AccessControl import ClassSecurityInfo ...@@ -37,7 +37,7 @@ from AccessControl import ClassSecurityInfo
from Acquisition import aq_base from Acquisition import aq_base
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
from Products.ERP5Type.Cache import getTransactionCache from Products.ERP5Type.Cache import getReadOnlyTransactionCache
from Products.CMFCategory import _dtmldir from Products.CMFCategory import _dtmldir
from Products.CMFCore.PortalFolder import ContentFilter from Products.CMFCore.PortalFolder import ContentFilter
from Products.CMFCategory.Renderer import Renderer from Products.CMFCategory.Renderer import Renderer
...@@ -199,7 +199,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -199,7 +199,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
Returns a Category object from a given category url Returns a Category object from a given category url
and optionnal base category id and optionnal base category id
""" """
cache = getTransactionCache(self) cache = getReadOnlyTransactionCache(self)
if cache is not None: if cache is not None:
key = ('getCategoryValue', relative_url, base_category) key = ('getCategoryValue', relative_url, base_category)
try: try:
...@@ -766,7 +766,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -766,7 +766,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
'getSingleCategoryAcquiredMembershipList' ) 'getSingleCategoryAcquiredMembershipList' )
def getSingleCategoryAcquiredMembershipList(self, context, base_category, base=0, def getSingleCategoryAcquiredMembershipList(self, context, base_category, base=0,
spec=(), filter=None, acquired_object_dict = None, **kw ): spec=(), filter=None, acquired_object_dict = None, **kw ):
cache = getTransactionCache(self) cache = getReadOnlyTransactionCache(self)
if cache is not None: if cache is not None:
key = ('getSingleCategoryAcquiredMembershipList', context._p_oid, base_category, base, spec, key = ('getSingleCategoryAcquiredMembershipList', context._p_oid, base_category, base, spec,
filter, str(kw)) filter, str(kw))
...@@ -1399,7 +1399,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1399,7 +1399,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
Finds an object from a relative_url Finds an object from a relative_url
Method is public since we use restrictedTraverse Method is public since we use restrictedTraverse
""" """
cache = getTransactionCache(self) cache = getReadOnlyTransactionCache(self)
if cache is not None: if cache is not None:
key = ('resolveCategory', relative_url) key = ('resolveCategory', relative_url)
try: try:
......
...@@ -48,7 +48,7 @@ from Products.ERP5Type.Utils2 import _getListFor ...@@ -48,7 +48,7 @@ from Products.ERP5Type.Utils2 import _getListFor
from Products.ERP5Type.Accessor.TypeDefinition import list_types from Products.ERP5Type.Accessor.TypeDefinition import list_types
from Products.ERP5Type.Accessor import Base as BaseAccessor from Products.ERP5Type.Accessor import Base as BaseAccessor
from Products.ERP5Type.XMLExportImport import Base_asXML from Products.ERP5Type.XMLExportImport import Base_asXML
from Products.ERP5Type.Cache import CachingMethod, clearCache, getTransactionCache from Products.ERP5Type.Cache import CachingMethod, clearCache, getReadOnlyTransactionCache
from Products.CMFCore.WorkflowCore import ObjectDeleted from Products.CMFCore.WorkflowCore import ObjectDeleted
from Accessor import WorkflowState from Accessor import WorkflowState
...@@ -1224,7 +1224,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -1224,7 +1224,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
""" """
Returns the portal object Returns the portal object
""" """
cache = getTransactionCache(self) cache = getReadOnlyTransactionCache(self)
if cache is not None: if cache is not None:
key = 'getPortalObject' key = 'getPortalObject'
try: try:
......
...@@ -153,20 +153,20 @@ def clearCache(): ...@@ -153,20 +153,20 @@ def clearCache():
# TransactionCache is a cache per transaction. The purpose of this cache is # TransactionCache is a cache per transaction. The purpose of this cache is
# to accelerate some heavy read-only operations. Note that this must not be # to accelerate some heavy read-only operations. Note that this must not be
# enabled when a trasaction may modify ZODB objects. # enabled when a trasaction may modify ZODB objects.
def getTransactionCache(context): def getReadOnlyTransactionCache(context):
"""Get the transaction cache. """Get the transaction cache.
""" """
try: try:
return context.REQUEST['_erp5_transaction_cache'] return context.REQUEST['_erp5_read_only_transaction_cache']
except KeyError: except KeyError:
return None return None
def enableTransactionCache(context): def enableReadOnlyTransactionCache(context):
"""Enable the transaction cache. """Enable the transaction cache.
""" """
context.REQUEST.set('_erp5_transaction_cache', {}) context.REQUEST.set('_erp5_read_only_transaction_cache', {})
def disableTransactionCache(context): def disableReadOnlyTransactionCache(context):
"""Disable the transaction cache. """Disable the transaction cache.
""" """
context.REQUEST.set('_erp5_transaction_cache', None) context.REQUEST.set('_erp5_read_only_transaction_cache', None)
...@@ -59,12 +59,12 @@ except ImportError: ...@@ -59,12 +59,12 @@ except ImportError:
psyco = None psyco = None
try: try:
from Products.ERP5Type.Cache import enableTransactionCache, disableTransactionCache from Products.ERP5Type.Cache import enableReadOnlyTransactionCache, disableReadOnlyTransactionCache
except ImportError: except ImportError:
def doNothing(context): def doNothing(context):
pass pass
enableTransactionCache = doNothing enableReadOnlyTransactionCache = doNothing
disableTransactionCache = doNothing disableReadOnlyTransactionCache = doNothing
UID_BUFFER_SIZE = 300 UID_BUFFER_SIZE = 300
...@@ -1047,7 +1047,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -1047,7 +1047,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
try: try:
if not disable_cache: if not disable_cache:
enableTransactionCache(self) enableReadOnlyTransactionCache(self)
method_kw_dict = {} method_kw_dict = {}
for method_name in method_id_list: for method_name in method_id_list:
...@@ -1135,7 +1135,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -1135,7 +1135,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
raise raise
finally: finally:
if not disable_cache: if not disable_cache:
disableTransactionCache(self) disableReadOnlyTransactionCache(self)
if psyco is not None: psyco.bind(catalogObjectList) if psyco is not None: psyco.bind(catalogObjectList)
......
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