Commit d9a1bc37 authored by Julien Muchembled's avatar Julien Muchembled

Really fix caching_class_method_decorator and comment it

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29752 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1ed9078b
......@@ -281,5 +281,12 @@ def generateCacheIdWithoutFirstArg(method_id, *args, **kwd):
def caching_class_method_decorator(*args, **kw):
kw.setdefault('cache_id_func', generateCacheIdWithoutFirstArg)
def wrapped(method):
return lambda *a, **k: CachingMethod(method, *args, **kw)(*a, **k)
# The speed of returned function must be fast
# so we instanciate CachingMethod now.
caching_method = CachingMethod(method, *args, **kw)
# Here, we can't return caching_method directly because an instanciated
# class with a __call__ method does not behave exactly like a simple
# function: if the decorator is used to create a method, the instance on
# which the method is called would not be passed as first parameter.
return lambda *args, **kw: caching_method(*args, **kw)
return wrapped
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