# HG changeset patch # User Sylvain Thénault # Date 1245392603 -7200 # Node ID b451bd56c9cd00097413a38d54a3890037e9be01 # Parent 344ca533ee9de577830d26ae356a48e5d89f3d4d fix change_state to allow state as eid/state name/state entity/ diff -r 344ca533ee9d -r b451bd56c9cd common/mixins.py --- 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: