common/mixins.py
branchstable
changeset 2117 b451bd56c9cd
parent 2005 e8032965f37a
child 2144 51c84d585456
child 2727 5275d015834c
--- a/common/mixins.py	Fri Jun 19 08:22:51 2009 +0200
+++ b/common/mixins.py	Fri Jun 19 08:23:23 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: