common/mixins.py
changeset 2144 51c84d585456
parent 2058 7ef12c03447c
parent 2117 b451bd56c9cd
child 2613 5e19c2bb370e
--- a/common/mixins.py	Tue Jun 23 13:31:35 2009 +0200
+++ b/common/mixins.py	Tue Jun 23 13:36:38 2009 +0200
@@ -191,11 +191,18 @@
             return rset.get_entity(0, 0)
         return None
 
-    def change_state(self, stateeid, trcomment=None, trcommentformat=None):
+    def change_state(self, state, trcomment=None, trcommentformat=None):
         """change the entity's state according to a state defined in given
         parameters
         """
-        assert not isinstance(stateeid, basestring), 'change_state wants a state eid'
+        if isinstance(state, basestring):
+            state = self.wf_state(state)
+            assert state is not None, 'not a %s state: %s' % (self.id, state)
+        if hasattr(state, 'eid'):
+            stateeid = state.eid
+        else:
+            stateeid = state
+        stateeid = typed_eid(stateeid)
         if trcomment:
             self.req.set_shared_data('trcomment', trcomment)
         if trcommentformat: