[selectors] fix on_fire_transition for cases where change_state is called (eg no transition specified)
--- 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)
--- 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']])