[Erp5-report] r29752 - /erp5/trunk/products/ERP5Type/Cache.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Oct 16 13:43:35 CEST 2009


Author: jm
Date: Fri Oct 16 13:43:32 2009
New Revision: 29752

URL: http://svn.erp5.org?rev=29752&view=rev
Log:
Really fix caching_class_method_decorator and comment it

Modified:
    erp5/trunk/products/ERP5Type/Cache.py

Modified: erp5/trunk/products/ERP5Type/Cache.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Cache.py?rev=29752&r1=29751&r2=29752&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Cache.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Cache.py [utf8] Fri Oct 16 13:43:32 2009
@@ -281,5 +281,12 @@
 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




More information about the Erp5-report mailing list