Commit 37df407c authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[wf] new iter_worfklows method on workflow

--HG--
branch : 3.5
parent fed52d317ba7
......@@ -40,6 +40,23 @@ class Workflow(AnyEntity):
return self.workflow_of[0].rest_path(), {'vid': 'workflow'}
return super(Workflow, self).after_deletion_path()
def iter_workflows(self, _done=None):
"""return an iterator on actual workflows, eg this workflow and its
subworkflows
"""
# infinite loop safety belt
if _done is None:
_done = set()
yield self
_done.add(self.eid)
for tr in self.req.execute('Any T WHERE T is WorkflowTransition, '
'T transition_of WF, WF eid %(wf)s',
{'wf': self.eid}).entities():
if tr.subwf.eid in _done:
continue
for subwf in tr.subwf.iter_workflows(_done):
yield subwf
# state / transitions accessors ############################################
def state_by_name(self, statename):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment