nicer warnings
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 23 Sep 2009 09:35:36 +0200
changeset 3383 c6aff16e5aed
parent 3382 435286b8fe10
child 3396 fb261afd49cd
nicer warnings
server/hook.py
vregistry.py
--- a/server/hook.py	Wed Sep 23 09:35:28 2009 +0200
+++ b/server/hook.py	Wed Sep 23 09:35:36 2009 +0200
@@ -137,14 +137,16 @@
 
     @classproperty
     def __regid__(cls):
-        warn('[3.6] %s: please specify an id for your hook' % cls)
+        warn('[3.6] %s.%s: please specify an id for your hook'
+             % (cls.__module__, cls.__name__), DeprecationWarning)
         return str(id(cls))
 
     @classmethod
     def __registered__(cls, vreg):
         super(Hook, cls).__registered__(vreg)
         if getattr(cls, 'accepts', None):
-            warn('[3.6] %s: accepts is deprecated, define proper __select__' % cls)
+            warn('[3.6] %s.%s: accepts is deprecated, define proper __select__'
+                 % (cls.__module__, cls.__name__), DeprecationWarning)
             rtypes = []
             for ertype in cls.accepts:
                 if ertype.islower():
@@ -165,8 +167,9 @@
 
     def __call__(self):
         if hasattr(self, 'call'):
-            warn('[3.6] %s: call is deprecated, implements __call__' % self.__class__,
-                 DeprecationWarning)
+            cls = self.__class__
+            warn('[3.6] %s.%s: call is deprecated, implements __call__'
+                 % (cls.__module__, cls.__name__), DeprecationWarning)
             if self.event.endswith('_relation'):
                 self.call(self._cw, self.eidfrom, self.rtype, self.eidto)
             elif 'delete' in self.event:
--- a/vregistry.py	Wed Sep 23 09:35:28 2009 +0200
+++ b/vregistry.py	Wed Sep 23 09:35:36 2009 +0200
@@ -61,7 +61,8 @@
 def class_regid(cls):
     """returns a unique identifier for an appobject class"""
     if 'id' in cls.__dict__:
-        warn('%s: id is deprecated, use __regid__')
+        warn('%s.%s: id is deprecated, use __regid__'
+             % (cls.__module__, cls.__name__), DeprecationWarning)
         cls.__regid__ = cls.id
     if hasattr(cls, 'id'):
         return cls.id