Commit c3033d15 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

simplify the definition of caching_class_method_decorator, thanks to Julien.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29739 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9f126c0f
...@@ -278,13 +278,6 @@ def generateCacheIdWithoutFirstArg(method_id, *args, **kwd): ...@@ -278,13 +278,6 @@ def generateCacheIdWithoutFirstArg(method_id, *args, **kwd):
# is 'self' that can be ignored to create a cache id. # is 'self' that can be ignored to create a cache id.
return str((method_id, args[1:], kwd)) return str((method_id, args[1:], kwd))
class caching_class_method_decorator: def caching_class_method_decorator(*args, **kw):
def __init__(self, *args, **kw): kw.setdefault('cache_id_func', generateCacheIdWithoutFirstArg)
self.args = args return lambda method: CachingMethod(method, *args, **kw)
kw.setdefault(
'cache_id_func', generateCacheIdWithoutFirstArg)
self.kw = kw
def __call__(self, method):
caching_method = CachingMethod(method, *self.args, **self.kw)
return lambda *args, **kw: caching_method(*args, **kw)
...@@ -84,11 +84,8 @@ except ImportError: ...@@ -84,11 +84,8 @@ except ImportError:
self.function = callable self.function = callable
def __call__(self, *opts, **kw): def __call__(self, *opts, **kw):
return self.function(*opts, **kw) return self.function(*opts, **kw)
class caching_class_method_decorator: def caching_class_method_decorator(*args, **kw):
def __init__(self, *args, **kw): return lambda method: method
pass
def __call__(self, method):
return method
enableReadOnlyTransactionCache = doNothing enableReadOnlyTransactionCache = doNothing
disableReadOnlyTransactionCache = doNothing disableReadOnlyTransactionCache = doNothing
......
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