916 wf = self.cmd_create_entity('Workflow', name=unicode(name), |
916 wf = self.cmd_create_entity('Workflow', name=unicode(name), |
917 **kwargs) |
917 **kwargs) |
918 if not isinstance(wfof, (list, tuple)): |
918 if not isinstance(wfof, (list, tuple)): |
919 wfof = (wfof,) |
919 wfof = (wfof,) |
920 for etype in wfof: |
920 for etype in wfof: |
921 rset = self.rqlexec('SET X workflow_of ET ' |
921 rset = self.rqlexec( |
922 'WHERE X eid %(x)s, ET name %(et)s', |
922 'SET X workflow_of ET WHERE X eid %(x)s, ET name %(et)s', |
923 {'x': wf.eid, 'et': etype}, 'x') |
923 {'x': wf.eid, 'et': etype}, 'x', ask_confirm=False) |
924 assert rset, 'unexistant entity type %s' % etype |
924 assert rset, 'unexistant entity type %s' % etype |
925 if default: |
925 if default: |
926 rset = self.rqlexec('SET ET default_workflow X ' |
926 self.rqlexec( |
927 'WHERE X eid %(x)s, ET name %(et)s', |
927 'SET ET default_workflow X WHERE X eid %(x)s, ET name %(et)s', |
928 {'x': wf.eid, 'et': etype}, 'x') |
928 {'x': wf.eid, 'et': etype}, 'x', ask_confirm=False) |
929 if commit: |
929 if commit: |
930 self.commit() |
930 self.commit() |
931 return wf |
931 return wf |
932 |
932 |
933 # XXX remove once cmd_add_[state|transition] are removed |
933 # XXX remove once cmd_add_[state|transition] are removed |