diff --git a/product/ERP5Type/Cache.py b/product/ERP5Type/Cache.py index 7f0def74d81aa2726dc9b275864efa62423f0821..534cff0239ad9e96e63bcdf565e27a0d42d4dab7 100644 --- a/product/ERP5Type/Cache.py +++ b/product/ERP5Type/Cache.py @@ -158,7 +158,7 @@ class CachingMethod: 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 @@ class CachingMethod: 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 @@ class CachingMethod: ## 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 @@ def generateCacheIdWithoutFirstArg(method_id, *args, **kwd): # 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. diff --git a/product/ERP5Type/ERP5Type.py b/product/ERP5Type/ERP5Type.py index af31083fb807608f21b4fe90fa8dc5639eb0dcb2..54e627cb73e71a46be2c5dd2cb94894e47c840dc 100644 --- a/product/ERP5Type/ERP5Type.py +++ b/product/ERP5Type/ERP5Type.py @@ -526,7 +526,7 @@ class ERP5TypeInformation(XMLObject, _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): diff --git a/product/ZSQLCatalog/SQLCatalog.py b/product/ZSQLCatalog/SQLCatalog.py index 9536b61b28ec39f7faf64a16fe768ad65db6ef03..b3c64f6ce24e98b11a5cf31faa1bb681ada1919a 100644 --- a/product/ZSQLCatalog/SQLCatalog.py +++ b/product/ZSQLCatalog/SQLCatalog.py @@ -71,7 +71,7 @@ except ImportError: 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 @@ except ImportError: 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 @@ class Catalog(Folder, @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 @@ class Catalog(Folder, @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 = {}