# HG changeset patch # User Sylvain Thénault # Date 1304413352 -7200 # Node ID a448e470c1503ccb1db82d44fd13ce20eba6cb6f # Parent 117dbb11a42e049a147c241edcbce03d71aaedfa [selectors] fix on_fire_transition for cases where change_state is called (eg no transition specified) diff -r 117dbb11a42e -r a448e470c150 selectors.py --- a/selectors.py Mon May 02 17:24:51 2011 +0200 +++ b/selectors.py Tue May 03 11:02:32 2011 +0200 @@ -1244,9 +1244,10 @@ :class:`cubicweb.entities.wfobjs.TrInfo` for more information. """ def match_etype_and_transition(trinfo): - # is_instance() first two arguments are 'cls' (unused, so giving None is - # fine) and the request/session - return (trinfo.transition.name == tr_name + # take care trinfo.transition is None when calling change_state + return (trinfo.transition and trinfo.transition.name == tr_name + # is_instance() first two arguments are 'cls' (unused, so giving + # None is fine) and the request/session and is_instance(etype)(None, trinfo._cw, entity=trinfo.for_entity)) return is_instance('TrInfo') & score_entity(match_etype_and_transition) diff -r 117dbb11a42e -r a448e470c150 test/unittest_rset.py --- a/test/unittest_rset.py Mon May 02 17:24:51 2011 +0200 +++ b/test/unittest_rset.py Tue May 03 11:02:32 2011 +0200 @@ -114,7 +114,6 @@ description=[['CWUser', 'String']] * 3) rs.req = self.request() rs.vreg = self.vreg - self.assertEqual(rs.limit(2).rows, [[12000, 'adim'], [13000, 'syt']]) rs2 = rs.limit(2, offset=1) self.assertEqual(rs2.rows, [[13000, 'syt'], [14000, 'nico']])