Commits

João Pedro Francese committed 2a24260

Making method_cache work with classmethods.

  • Participants
  • Parent commits 601b8d1

Comments (0)

Files changed (1)

File inoa/utils/method_cache.py

         
         def x(instance, *args, **kwargs):
             key = sha224(str(method.__module__) + str(method.__name__) + \
-                str(instance.id) + str(args) + str(kwargs)).hexdigest()
+                str(getattr(instance, 'id', 0)) + str(args) + str(kwargs)).hexdigest()
             
             skip_method_cache = kwargs.pop('skip_method_cache', False)
             if not skip_method_cache and hasattr(instance, key):
-                # has on class cache, return that
+                # has on instance cache, return that
                 result = getattr(instance, key)
             else:
                 result = cache.get(key)
         
         return x
     
-    return inner_cache
+    return inner_cache