# HG changeset patch # User Sylvain Thénault # Date 1251217829 -7200 # Node ID f221ba8552abbc5a375db1741644e8ca7b2e8cf1 # Parent dfb3506647e46bae8ef8d7a05cd38c915814b612 [wf] new method on WorkflowableMixIn to get the transition which had led to the current sub-workflow diff -r dfb3506647e4 -r f221ba8552ab entities/wfobjs.py --- a/entities/wfobjs.py Tue Aug 25 18:29:36 2009 +0200 +++ b/entities/wfobjs.py Tue Aug 25 18:30:29 2009 +0200 @@ -476,6 +476,26 @@ # XXX try to find matching transition? return self._add_trinfo(comment, commentformat, tr and tr.eid, stateeid) + def subworkflow_input_transition(self): + """return the transition which has went through the current sub-workflow + """ + if self.main_workflow.eid == self.current_workflow.eid: + return # doesn't make sense + subwfentries = [] + for trinfo in reversed(self.workflow_history): + if (trinfo.transition and + trinfo.previous_state.workflow.eid != trinfo.new_state.workflow.eid): + # entering or leaving a subworkflow + if (subwfentries and + subwfentries[-1].new_state.workflow.eid == trinfo.previous_state.workflow.eid): + # leave + del subwfentries[-1] + else: + # enter + subwfentries.append(trinfo) + if not subwfentries: + return None + return subwfentries[-1].transition def clear_all_caches(self): super(WorkflowableMixIn, self).clear_all_caches()