# HG changeset patch # User Sylvain Thénault # Date 1251200162 -7200 # Node ID 79185b3ccf2c12a76d49b947d7d01fc4084667e3 # Parent 31c24caf6961651bfd3a2cb1c0c2700a43d5b6e9 cleanup diff -r 31c24caf6961 -r 79185b3ccf2c entities/test/unittest_wfobjs.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', diff -r 31c24caf6961 -r 79185b3ccf2c server/hooks.py --- 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: