--- a/hooks/workflow.py Tue Sep 29 15:58:44 2009 +0200
+++ b/hooks/workflow.py Wed Sep 30 18:57:42 2009 +0200
@@ -47,6 +47,19 @@
session.super_session.add_relation(entity.eid, 'in_state',
state.eid)
+
+class _FireAutotransitionOp(PreCommitOperation):
+ """try to fire auto transition after state changes"""
+
+ def precommit_event(self):
+ session = self.session
+ entity = self.entity
+ autotrs = list(entity.possible_transitions('auto'))
+ if autotrs:
+ assert len(autotrs) == 1
+ entity.fire_transition(autotrs[0])
+
+
class _WorkflowChangedOp(hook.Operation):
"""fix entity current state when changing its workflow"""
@@ -206,6 +219,7 @@
nocheck = session.transaction_data.setdefault('skip-security', set())
nocheck.add((entity.eid, 'from_state', fromstate.eid))
nocheck.add((entity.eid, 'to_state', deststateeid))
+ FireAutotransitionOp(session, entity=forentity)
class FiredTransitionHook(WorkflowHook):