cleanup 3.5
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 25 Aug 2009 13:36:02 +0200
branch3.5
changeset 2985 79185b3ccf2c
parent 2984 31c24caf6961
child 2986 d8f2e53702be
cleanup
entities/test/unittest_wfobjs.py
server/hooks.py
--- a/entities/test/unittest_wfobjs.py	Tue Aug 25 13:35:45 2009 +0200
+++ b/entities/test/unittest_wfobjs.py	Tue Aug 25 13:36:02 2009 +0200
@@ -212,8 +212,7 @@
         self.assertEquals(ex.errors, {'custom_workflow': u'workflow has no initial state'})
 
     def test_custom_wf_bad_etype(self):
-        """try to set a custom workflow which has no initial state"""
-        self.member.fire_transition('deactivate')
+        """try to set a custom workflow which doesn't apply to entity type"""
         wf = add_wf(self, 'Company')
         wf.add_state('asleep', initial=True)
         self.execute('SET X custom_workflow WF WHERE X eid %(x)s, WF eid %(wf)s',
--- a/server/hooks.py	Tue Aug 25 13:35:45 2009 +0200
+++ b/server/hooks.py	Tue Aug 25 13:36:02 2009 +0200
@@ -515,6 +515,10 @@
                                                    state.eid)
 
 
+def set_initial_state_after_add(session, entity):
+    SetInitialStateOp(session, entity=entity)
+
+
 def before_add_in_state(session, eidfrom, rtype, eidto):
     """check state apply"""
     nocheck = session.transaction_data.setdefault('skip-security', ())
@@ -535,14 +539,13 @@
                         "want to set a custom workflow for this entity first.")
         raise ValidationError(eidfrom, {'in_state': msg})
 
-def set_initial_state_after_add(session, entity):
-    SetInitialStateOp(session, entity=entity)
-
 
 class WorkflowChangedOp(PreCommitOperation):
     """fix entity current state when changing its workflow"""
 
     def precommit_event(self):
+        # notice that enforcement that new workflow apply to the entity's type is
+        # done by schema rule, no need to check it here
         session = self.session
         pendingeids = session.transaction_data.get('pendingeids', ())
         if self.eid in pendingeids: