[migration] add_workflow now ensure the entity type is actually workflowable, and a new make_workflowable migration function is available to make an entity type workflowable (closes #1382720)
--- a/server/migractions.py Tue Jan 11 15:23:29 2011 +0100
+++ b/server/migractions.py Tue Jan 11 15:33:38 2011 +0100
@@ -1218,6 +1218,12 @@
# Workflows handling ######################################################
+ def cmd_make_workflowable(self, etype):
+ """add workflow relations to an entity type to make it workflowable"""
+ self.cmd_add_relation_definition(etype, 'in_state', 'State')
+ self.cmd_add_relation_definition(etype, 'custom_workflow', 'Workflow')
+ self.cmd_add_relation_definition('TrInfo', 'wf_info_for', etype)
+
def cmd_add_workflow(self, name, wfof, default=True, commit=False,
**kwargs):
"""
@@ -1239,7 +1245,13 @@
**kwargs)
if not isinstance(wfof, (list, tuple)):
wfof = (wfof,)
+ def _missing_wf_rel(etype):
+ return 'missing workflow relations, see make_workflowable(%s)' % etype
for etype in wfof:
+ eschema = self.repo.schema[etype]
+ assert 'in_state' in eschema.subjrels, _missing_wf_rel(etype)
+ assert 'custom_workflow' in eschema.subjrels, _missing_wf_rel(etype)
+ assert 'wf_info_for' in eschema.objrels, _missing_wf_rel(etype)
rset = self.rqlexec(
'SET X workflow_of ET WHERE X eid %(x)s, ET name %(et)s',
{'x': wf.eid, 'et': etype}, ask_confirm=False)