[wf] oops, BaseTransition.__init__ may be called for subclasses 3.5
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 21 Aug 2009 14:50:20 +0200
branch3.5
changeset 2954 48507919b6e3
parent 2951 d0b77dd27740
child 2955 6bb5025c9fc7
[wf] oops, BaseTransition.__init__ may be called for subclasses
entities/test/unittest_wfobjs.py
entities/wfobjs.py
--- a/entities/test/unittest_wfobjs.py	Fri Aug 21 09:03:30 2009 +0200
+++ b/entities/test/unittest_wfobjs.py	Fri Aug 21 14:50:20 2009 +0200
@@ -198,6 +198,7 @@
         self.assertEquals(len(transitions), 1)
         self.assertEquals(transitions[0].name, 'tr1')
 
+
 class CustomWorkflowTC(EnvBasedTC):
 
     def setup_database(self):
--- a/entities/wfobjs.py	Fri Aug 21 09:03:30 2009 +0200
+++ b/entities/wfobjs.py	Fri Aug 21 14:50:20 2009 +0200
@@ -124,7 +124,9 @@
     fetch_attrs, fetch_order = fetch_config(['name'])
 
     def __init__(self, *args, **kwargs):
-        raise Exception('should not be instantiated')
+        if self.id == 'BaseTransition':
+            raise Exception('should not be instantiated')
+        super(BaseTransition, self).__init__(*args, **kwargs)
 
     def may_be_fired(self, eid):
         """return true if the logged user may fire this transition