defer trinfo creation when cancelling subworkflow stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 14 Oct 2009 12:43:35 +0200
branchstable
changeset 3662 9eeadad82d93
parent 3651 633b8971c95a
child 3663 c74d8ec4cdb2
defer trinfo creation when cancelling subworkflow
server/hooks.py
--- a/server/hooks.py	Tue Oct 13 09:17:53 2009 +0200
+++ b/server/hooks.py	Wed Oct 14 12:43:35 2009 +0200
@@ -553,13 +553,20 @@
     assert forentity.current_state.eid == entity['to_state'], (
         forentity.eid, forentity.current_state.name)
     if forentity.main_workflow.eid != forentity.current_workflow.eid:
+        SubWorkflowExitOp(session, forentity=forentity, trinfo=entity)
+
+class SubWorkflowExitOp(PreCommitOperation):
+    def precommit_event(self):
+        session = self.session
+        forentity = self.forentity
+        trinfo = self.trinfo
         # we're in a subworkflow, check if we've reached an exit point
         wftr = forentity.subworkflow_input_transition()
         if wftr is None:
             # inconsistency detected
-            msg = entity.req._("state doesn't belong to entity's current workflow")
-            raise ValidationError(entity.eid, {'to_state': msg})
-        tostate = wftr.get_exit_point(forentity, entity['to_state'])
+            msg = session._("state doesn't belong to entity's current workflow")
+            raise ValidationError(self.trinfo.eid, {'to_state': msg})
+        tostate = wftr.get_exit_point(forentity, trinfo['to_state'])
         if tostate is not None:
             # reached an exit point
             msg = session._('exiting from subworkflow %s')