[Erp5-report] r29775 - in /erp5/trunk/products: ERP5Type/ ZSQLCatalog/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Oct 19 09:17:26 CEST 2009
Author: kazuhiko
Date: Mon Oct 19 09:17:24 2009
New Revision: 29775
URL: http://svn.erp5.org?rev=29775&view=rev
Log:
rename decorator function name and id generator argument name.
* caching_class_method_decorator -> caching_instance_method
* cache_id_func -> cache_id_generator
Modified:
erp5/trunk/products/ERP5Type/Cache.py
erp5/trunk/products/ERP5Type/ERP5Type.py
erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
Modified: erp5/trunk/products/ERP5Type/Cache.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Cache.py?rev=29775&r1=29774&r2=29775&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Cache.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Cache.py [utf8] Mon Oct 19 09:17:24 2009
@@ -158,7 +158,7 @@
def __init__(self, callable_object, id, cache_duration=180,
cache_factory=DEFAULT_CACHE_FACTORY,
- cache_id_func=None):
+ cache_id_generator=None):
"""Wrap a callable object in a caching method.
callable_object must be callable.
@@ -176,7 +176,7 @@
self.callable_object = callable_object
self.cache_duration = cache_duration
self.cache_factory = cache_factory
- self.cache_id_func = cache_id_func
+ self.cache_id_generator = cache_id_generator
def __call__(self, *args, **kwd):
"""Call the method or return cached value using appropriate cache plugin """
@@ -223,9 +223,9 @@
## generate cache id out of arguments passed.
## depending on arguments we may have different
## cache_id for same method_id
- cache_id_func = self.cache_id_func
- if cache_id_func is not None:
- return cache_id_func(method_id, *args, **kwd)
+ cache_id_generator = self.cache_id_generator
+ if cache_id_generator is not None:
+ return cache_id_generator(method_id, *args, **kwd)
return str((method_id, args, kwd))
allow_class(CachingMethod)
@@ -278,8 +278,8 @@
# is 'self' that can be ignored to create a cache id.
return str((method_id, args[1:], kwd))
-def caching_class_method_decorator(*args, **kw):
- kw.setdefault('cache_id_func', generateCacheIdWithoutFirstArg)
+def caching_instance_method(*args, **kw):
+ kw.setdefault('cache_id_generator', generateCacheIdWithoutFirstArg)
def wrapped(method):
# The speed of returned function must be fast
# so we instanciate CachingMethod now.
Modified: erp5/trunk/products/ERP5Type/ERP5Type.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/ERP5Type.py?rev=29775&r1=29774&r2=29775&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/ERP5Type.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/ERP5Type.py [utf8] Mon Oct 19 09:17:24 2009
@@ -526,7 +526,7 @@
_getRawActionInformationList,
id='_getRawActionInformationList',
cache_factory='erp5_content_long',
- cache_id_func=lambda method_id, *args, **kwd:str(method_id))
+ cache_id_generator=lambda method_id, *args, **kwd:str(method_id))
security.declarePrivate('getRawActionInformationList')
def getRawActionInformationList(self):
Modified: erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SQLCatalog.py?rev=29775&r1=29774&r2=29775&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SQLCatalog.py [utf8] (original)
+++ erp5/trunk/products/ZSQLCatalog/SQLCatalog.py [utf8] Mon Oct 19 09:17:24 2009
@@ -71,7 +71,7 @@
try:
from Products.ERP5Type.Cache import enableReadOnlyTransactionCache, \
disableReadOnlyTransactionCache, CachingMethod, \
- caching_class_method_decorator
+ caching_instance_method
except ImportError:
LOG('SQLCatalog', WARNING, 'Count not import CachingMethod, expect slowness.')
def doNothing(context):
@@ -84,7 +84,7 @@
self.function = callable
def __call__(self, *opts, **kw):
return self.function(*opts, **kw)
- def caching_class_method_decorator(*args, **kw):
+ def caching_instance_method(*args, **kw):
return lambda method: method
enableReadOnlyTransactionCache = doNothing
disableReadOnlyTransactionCache = doNothing
@@ -936,7 +936,7 @@
@profiler_decorator
@transactional_cache_decorator('SQLCatalog.getColumnMap')
@profiler_decorator
- @caching_class_method_decorator(id='SQLCatalog.getColumnMap', cache_factory='erp5_content_long')
+ @caching_instance_method(id='SQLCatalog.getColumnMap', cache_factory='erp5_content_long')
@profiler_decorator
def getColumnMap(self):
"""
@@ -2191,7 +2191,7 @@
@profiler_decorator
@transactional_cache_decorator('SQLCatalog._getSearchKeyDict')
@profiler_decorator
- @caching_class_method_decorator(id='SQLCatalog._getSearchKeyDict', cache_factory='erp5_content_long')
+ @caching_instance_method(id='SQLCatalog._getSearchKeyDict', cache_factory='erp5_content_long')
@profiler_decorator
def _getSearchKeyDict(self):
result = {}
More information about the Erp5-report
mailing list