[IMP] core: manage registries via an LRU.
[odoo/odoo.git] / openerp / tools / func.py
index baeae0b..0a36166 100644 (file)
@@ -20,7 +20,7 @@
 #
 ##############################################################################
 
-__all__ = ['synchronized', 'lazy_property']
+__all__ = ['synchronized', 'lazy_property', 'classproperty']
 
 from functools import wraps
 from inspect import getsourcefile
@@ -103,4 +103,12 @@ def compose(a, b):
         return a(b(*args, **kwargs))
     return wrapper
 
+
+class _ClassProperty(property):
+    def __get__(self, cls, owner):
+        return self.fget.__get__(None, owner)()
+
+def classproperty(func):
+    return _ClassProperty(classmethod(func))
+
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: