added replace_state method to ease workflow migration. backported from forge as a reminder, not really tested yet
--- a/entities/wfobjs.py Thu Dec 03 16:32:35 2009 +0100
+++ b/entities/wfobjs.py Fri Dec 04 19:45:19 2009 +0100
@@ -152,6 +152,19 @@
tr.add_exit_point(fromstate, tostate)
return tr
+ def replace_state(self, todelstate, replacement):
+ """migration convenience method"""
+ if not hasattr(todelstate, 'eid'):
+ todelstate = self.state_by_name(todelstate)
+ if not hasattr(replacement, 'eid'):
+ replacement = self.state_by_name(replacement)
+ execute = self._cw.unsafe_execute
+ execute('SET X in_state S WHERE S eid %(s)s', {'s': todelstate.eid}, 's')
+ execute('SET X from_state NS WHERE X to_state OS, OS eid %(os)s, NS eid %(ns)s',
+ {'os': todelstate.eid, 'ns': newstate.eid}, 's')
+ execute('SET X to_state NS WHERE X to_state OS, OS eid %(os)s, NS eid %(ns)s',
+ {'os': todelstate.eid, 'ns': newstate.eid}, 's')
+
class BaseTransition(AnyEntity):
"""customized class for abstract transition