take care not selecting published state from another workflow
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 20 Oct 2009 17:23:47 +0200
changeset 134 5a91d8db61a2
parent 133 c806a41eecf2
child 135 708cbacc4d77
take care not selecting published state from another workflow
migration/1.7.0_Any.py
--- a/migration/1.7.0_Any.py	Tue Oct 20 17:23:16 2009 +0200
+++ b/migration/1.7.0_Any.py	Tue Oct 20 17:23:47 2009 +0200
@@ -4,19 +4,23 @@
 
 
 # add BlogEntry workflow
-bwf = add_workflow(_('default BlogEntry workflow'), 'BlogEntry')
+if confirm('add blog entry workflow'):
+    bwf = add_workflow(_('default BlogEntry workflow'), 'BlogEntry')
 
-draft = bwf.add_state(_('draft'), initial=True)
-published = bwf.add_state(_('published'))
+    draft = bwf.add_state(_('draft'), initial=True)
+    published = bwf.add_state(_('published'))
 
-publish = bwf.add_transition(_('publish'), draft, published,
-                             ('managers',))
-checkpoint()
+    publish = bwf.add_transition(_('publish'), draft, published,
+                                 ('managers',))
+    checkpoint()
 
 # set state to published for already existing blog entries
 blogentries = rql('Any B WHERE B is BlogEntry')
 
-for blogentry in blogentries:
-    session.unsafe_execute('SET B in_state S WHERE S name "published", B eid %(b)s', {'b': blogentry[0]})
+for eid, in blogentries:
+    session.unsafe_execute('SET B in_state S WHERE S name "published", '
+                           'S state_of WF, WF name "default BlogEntry workflow", '
+                           'B eid %(b)s',
+                           {'b': eid}, 'b')
 
 checkpoint()