[hooks] better message on bad .event class attribute stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 31 Mar 2010 14:50:30 +0200
branchstable
changeset 5116 a2ce436e00ad
parent 5115 2e43ef618d14
child 5117 10d252240b2b
[hooks] better message on bad .event class attribute
server/hook.py
--- a/server/hook.py	Wed Mar 31 14:46:04 2010 +0200
+++ b/server/hook.py	Wed Mar 31 14:50:30 2010 +0200
@@ -75,13 +75,6 @@
                     self.unregister(cls)
 
     def register(self, obj, **kwargs):
-        try:
-            iter(obj.events)
-        except AttributeError:
-            raise
-        except:
-            raise Exception('bad .events attribute %s on %s.%s' % (
-                obj.events, obj.__module__, obj.__name__))
         for event in obj.events:
             if event not in ALL_HOOKS:
                 raise Exception('bad event %s on %s.%s' % (
@@ -207,8 +200,14 @@
     enabled = True
 
     @classproperty
-    def __registries__(self):
-        return ['%s_hooks' % ev for ev in self.events]
+    def __registries__(cls):
+        try:
+            return ['%s_hooks' % ev for ev in cls.events]
+        except AttributeError:
+            raise
+        except TypeError:
+            raise Exception('bad .events attribute %s on %s.%s' % (
+                cls.events, cls.__module__, cls.__name__))
 
     @classproperty
     def __regid__(cls):