[Erp5-report] r38367 jm - in /erp5/trunk/products: CMFCategory/ ERP5/Document/ ERP5/mixin/ ...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Sep 14 15:56:33 CEST 2010


Author: jm
Date: Tue Sep 14 15:56:32 2010
New Revision: 38367

URL: http://svn.erp5.org?rev=38367&view=rev
Log:
Same for *ReadOnlyTransactionCache

Modified:
    erp5/trunk/products/CMFCategory/CategoryTool.py
    erp5/trunk/products/ERP5/Document/ContributionPredicate.py
    erp5/trunk/products/ERP5/Document/Predicate.py
    erp5/trunk/products/ERP5/Document/WebSection.py
    erp5/trunk/products/ERP5/mixin/extensible_traversable.py
    erp5/trunk/products/ERP5Type/Cache.py
    erp5/trunk/products/ERP5Type/Utils.py
    erp5/trunk/products/ZSQLCatalog/SQLCatalog.py

Modified: erp5/trunk/products/CMFCategory/CategoryTool.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFCategory/CategoryTool.py?rev=38367&r1=38366&r2=38367&view=diff
==============================================================================
--- erp5/trunk/products/CMFCategory/CategoryTool.py [utf8] (original)
+++ erp5/trunk/products/CMFCategory/CategoryTool.py [utf8] Tue Sep 14 15:56:32 2010
@@ -209,7 +209,7 @@ class CategoryTool( UniqueObject, Folder
         Returns a Category object from a given category url
         and optionnal base category id
       """
-      cache = getReadOnlyTransactionCache(self)
+      cache = getReadOnlyTransactionCache()
       if cache is not None:
         key = ('getCategoryValue', relative_url, base_category)
         try:
@@ -848,7 +848,7 @@ class CategoryTool( UniqueObject, Folder
                                       'getSingleCategoryAcquiredMembershipList' )
     def getSingleCategoryAcquiredMembershipList(self, context, base_category, base=0,
                                          spec=(), filter=None, acquired_object_dict = None, **kw ):
-      cache = getReadOnlyTransactionCache(self)
+      cache = getReadOnlyTransactionCache()
       if cache is not None:
         key = ('getSingleCategoryAcquiredMembershipList', context.getPhysicalPath(), base_category, base, spec,
                filter, str(kw))
@@ -1627,7 +1627,7 @@ class CategoryTool( UniqueObject, Folder
         if not isinstance(relative_url, str):
           # Handle parent base category is a special way
           return relative_url
-        cache = getReadOnlyTransactionCache(self)
+        cache = getReadOnlyTransactionCache()
         if cache is not None:
           cache_key = ('resolveCategory', relative_url)
           try:

Modified: erp5/trunk/products/ERP5/Document/ContributionPredicate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/ContributionPredicate.py?rev=38367&r1=38366&r2=38367&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/ContributionPredicate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/ContributionPredicate.py [utf8] Tue Sep 14 15:56:32 2010
@@ -97,10 +97,10 @@ class ContributionPredicate(Predicate, X
     # temporarily, if not enabled, because this part is strictly read-only,
     # and context.isMemberOf is very expensive, when the category list has
     # many items.
-    enabled = (getReadOnlyTransactionCache(self) is not None)
+    enabled = getReadOnlyTransactionCache() is not None
     try:
       if not enabled:
-        enableReadOnlyTransactionCache(self)
+        enableReadOnlyTransactionCache()
       for c in membership_criterion_category_list:
         bc = c.split('/', 1)[0]
         if (bc not in tested_base_category) and \
@@ -117,7 +117,7 @@ class ContributionPredicate(Predicate, X
                                      context.isMemberOf(c)
     finally:
       if not enabled:
-        disableReadOnlyTransactionCache(self)
+        disableReadOnlyTransactionCache()
 
     result = result and (0 not in tested_base_category.values())
     # Test method calls

Modified: erp5/trunk/products/ERP5/Document/Predicate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Predicate.py?rev=38367&r1=38366&r2=38367&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Predicate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Predicate.py [utf8] Tue Sep 14 15:56:32 2010
@@ -152,10 +152,10 @@ class Predicate(XMLObject):
     # temporarily, if not enabled, because this part is strictly read-only,
     # and context.isMemberOf is very expensive, when the category list has
     # many items.
-    enabled = (getReadOnlyTransactionCache(self) is not None)
+    enabled = getReadOnlyTransactionCache() is not None
     try:
       if not enabled:
-        enableReadOnlyTransactionCache(self)
+        enableReadOnlyTransactionCache()
       for c in membership_criterion_category_list:
         bc = c.split('/', 1)[0]
         if (bc not in tested_base_category) and \
@@ -177,7 +177,7 @@ class Predicate(XMLObject):
                                          strict_membership=strict_membership)
     finally:
       if not enabled:
-        disableReadOnlyTransactionCache(self)
+        disableReadOnlyTransactionCache()
 
 #        LOG('predicate test', 0,
 #            '%s after single membership to %s' % \

Modified: erp5/trunk/products/ERP5/Document/WebSection.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/WebSection.py?rev=38367&r1=38366&r2=38367&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/WebSection.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/WebSection.py [utf8] Tue Sep 14 15:56:32 2010
@@ -232,7 +232,7 @@ class WebSection(Domain, DocumentExtensi
         portal type dependent script:
           WebSection_getDefaultDocumentValue
       """
-      cache = getReadOnlyTransactionCache(self)
+      cache = getReadOnlyTransactionCache()
       if cache is not None:
         key = ('getDefaultDocumentValue', self)
         try:
@@ -264,7 +264,7 @@ class WebSection(Domain, DocumentExtensi
         portal type dependent script:
           WebSection_getDocumentValueList
       """
-      cache = getReadOnlyTransactionCache(self)
+      cache = getReadOnlyTransactionCache()
       if cache is not None:
         key = ('getDocumentValueList', self) + tuple(kw.items())
         try:
@@ -296,7 +296,7 @@ class WebSection(Domain, DocumentExtensi
         portal type dependent script:
           WebSection_getPermanentURL
       """
-      cache = getReadOnlyTransactionCache(self)
+      cache = getReadOnlyTransactionCache()
       if cache is not None:
         key = ('getPermanentURL', self, document.getPath())
         try:
@@ -325,7 +325,7 @@ class WebSection(Domain, DocumentExtensi
       """
       if document is None:
         document = self
-      cache = getReadOnlyTransactionCache(self)
+      cache = getReadOnlyTransactionCache()
       if cache is not None:
         key = ('getBreadcrumbItemList', self, document.getPath())
         try:
@@ -370,7 +370,7 @@ class WebSection(Domain, DocumentExtensi
         portal type dependent script:
           WebSection_getSiteMapTree
       """
-      cache = getReadOnlyTransactionCache(self)
+      cache = getReadOnlyTransactionCache()
       if cache is not None:
         key = ('getSiteMapTree', self) + tuple(kw.items())
         try:

Modified: erp5/trunk/products/ERP5/mixin/extensible_traversable.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/mixin/extensible_traversable.py?rev=38367&r1=38366&r2=38367&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/mixin/extensible_traversable.py [utf8] (original)
+++ erp5/trunk/products/ERP5/mixin/extensible_traversable.py [utf8] Tue Sep 14 15:56:32 2010
@@ -71,7 +71,7 @@ class BaseExtensibleTraversableMixin(Ext
 
   def _forceIdentification(self, request):
     # force identification (usable for extensible content)
-    cache = getReadOnlyTransactionCache(self)
+    cache = getReadOnlyTransactionCache()
     if cache is not None:
       key = ('__bobo_traverse__', self, 'user')
       try:

Modified: erp5/trunk/products/ERP5Type/Cache.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Cache.py?rev=38367&r1=38366&r2=38367&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Cache.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Cache.py [utf8] Tue Sep 14 15:56:32 2010
@@ -32,7 +32,7 @@ from time import time
 from AccessControl.SecurityInfo import allow_class
 from CachePlugins.BaseCache import CachedMethodError
 from zLOG import LOG, WARNING
-from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
+from Products.ERP5Type.TransactionalVariable import getTransactionalVariable, _MARKER
 from Products.ERP5Type.Utils import simple_decorator
 from warnings import warn
 
@@ -235,29 +235,20 @@ allow_class(CachingMethod)
 # 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
 # enabled when a transaction may modify ZODB objects.
-def getReadOnlyTransactionCache(context):
+def getReadOnlyTransactionCache(context=_MARKER):
   """Get the transaction cache.
   """
-  tv = getTransactionalVariable(context)
-  try:
-    return tv['read_only_transaction_cache']
-  except KeyError:
-    return None
+  return getTransactionalVariable(context).get('read_only_transaction_cache')
 
-def enableReadOnlyTransactionCache(context):
+def enableReadOnlyTransactionCache(context=_MARKER):
   """Enable the transaction cache.
   """
-  tv = getTransactionalVariable(context)
-  tv['read_only_transaction_cache'] = {}
+  getTransactionalVariable(context)['read_only_transaction_cache'] = {}
 
-def disableReadOnlyTransactionCache(context):
+def disableReadOnlyTransactionCache(context=_MARKER):
   """Disable the transaction cache.
   """
-  tv = getTransactionalVariable(context)
-  try:
-    del tv['read_only_transaction_cache']
-  except KeyError:
-    pass
+  getTransactionalVariable(context).pop('read_only_transaction_cache', None)
 
 ########################################################
 ## Old global cache functions                         ##

Modified: erp5/trunk/products/ERP5Type/Utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Utils.py?rev=38367&r1=38366&r2=38367&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Utils.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Utils.py [utf8] Tue Sep 14 15:56:32 2010
@@ -1310,9 +1310,8 @@ def createExpressionContext(object, port
   return ec
 
 def getExistingBaseCategoryList(portal, base_cat_list):
-  cache = getReadOnlyTransactionCache(portal)
+  cache = getReadOnlyTransactionCache()
   if cache is None:
-    from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
     cache = getTransactionalVariable()
   category_tool = portal.portal_categories
   new_base_cat_list = []

Modified: erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SQLCatalog.py?rev=38367&r1=38366&r2=38367&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SQLCatalog.py [utf8] (original)
+++ erp5/trunk/products/ZSQLCatalog/SQLCatalog.py [utf8] Tue Sep 14 15:56:32 2010
@@ -1407,7 +1407,7 @@ class Catalog(Folder,
 
     try:
       if not disable_cache:
-        enableReadOnlyTransactionCache(self)
+        enableReadOnlyTransactionCache()
 
       filter_dict = self.filter_dict
       catalogged_object_list_cache = {}
@@ -1531,7 +1531,7 @@ class Catalog(Folder,
           raise
     finally:
       if not disable_cache:
-        disableReadOnlyTransactionCache(self)
+        disableReadOnlyTransactionCache()
 
   if psyco is not None:
     psyco.bind(_catalogObjectList)




More information about the Erp5-report mailing list