189 {'n': trname, 'e': str(self.e_schema)}) |
189 {'n': trname, 'e': str(self.e_schema)}) |
190 if rset: |
190 if rset: |
191 return rset.get_entity(0, 0) |
191 return rset.get_entity(0, 0) |
192 return None |
192 return None |
193 |
193 |
194 def change_state(self, stateeid, trcomment=None, trcommentformat=None): |
194 def change_state(self, state, trcomment=None, trcommentformat=None): |
195 """change the entity's state according to a state defined in given |
195 """change the entity's state according to a state defined in given |
196 parameters |
196 parameters |
197 """ |
197 """ |
198 assert not isinstance(stateeid, basestring), 'change_state wants a state eid' |
198 if isinstance(state, basestring): |
|
199 state = self.wf_state(state) |
|
200 assert state is not None, 'not a %s state: %s' % (self.id, state) |
|
201 if hasattr(state, 'eid'): |
|
202 stateeid = state.eid |
|
203 else: |
|
204 stateeid = state |
|
205 stateeid = typed_eid(stateeid) |
199 if trcomment: |
206 if trcomment: |
200 self.req.set_shared_data('trcomment', trcomment) |
207 self.req.set_shared_data('trcomment', trcomment) |
201 if trcommentformat: |
208 if trcommentformat: |
202 self.req.set_shared_data('trcommentformat', trcommentformat) |
209 self.req.set_shared_data('trcommentformat', trcommentformat) |
203 self.req.execute('SET X in_state S WHERE X eid %(x)s, S eid %(s)s', |
210 self.req.execute('SET X in_state S WHERE X eid %(x)s, S eid %(s)s', |