added some assertion on expected hooks class attributes stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 09 Jul 2009 14:58:01 +0200
branchstable
changeset 2350 209a816a5fb4
parent 2349 b9e2c1b7b873
child 2351 dddee537e4d5
added some assertion on expected hooks class attributes
server/hooksmanager.py
--- a/server/hooksmanager.py	Thu Jul 09 14:56:50 2009 +0200
+++ b/server/hooksmanager.py	Thu Jul 09 14:58:01 2009 +0200
@@ -216,7 +216,14 @@
             cls.warning('%s hook has been disabled', cls)
             return
         done = set()
+        assert isinstance(cls.events, (tuple, list)), \
+               '%s: events is expected to be a tuple, not %s' % (
+            cls, type(cls.events))
         for event in cls.events:
+            if event == 'server_startup':
+                assert not cls.accepts or cls.accepts == ('Any',), \
+                       '%s doesnt make sense on server_startup' % cls.accepts
+                cls.accepts = ('Any',)
             for ertype in cls.accepts:
                 if (event, ertype) in done:
                     continue