[appobject] detect old-style property_defs and emit a deprectaion warning
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Wed, 23 Sep 2009 09:47:04 +0200
changeset 3390 ae50bd4b1631
parent 3389 59c0e6b34dd1
child 3391 b6564d9ca872
[appobject] detect old-style property_defs and emit a deprectaion warning
appobject.py
--- a/appobject.py	Wed Sep 23 08:14:45 2009 +0200
+++ b/appobject.py	Wed Sep 23 09:47:04 2009 +0200
@@ -11,6 +11,7 @@
 
 import types
 from logging import getLogger
+from warnings import warn
 
 from logilab.common.decorators import classproperty
 from logilab.common.deprecation import deprecated
@@ -250,7 +251,13 @@
         the right hook to create an instance for example). By default the
         appobject is returned without any transformation.
         """
-        pdefs = getattr(cls, 'cw_property_defs', {})
+        try:
+            pdefs = cls.property_defs
+        except AttributeError:
+            pdefs = getattr(cls, 'cw_property_defs', {})
+        else:
+            warn('property_defs is deprecated, use cw_property_defs in %s'
+                 % cls, DeprecationWarning)
         for propid, pdef in pdefs.items():
             pdef = pdef.copy() # may be shared
             pdef['default'] = getattr(cls, propid, pdef['default'])