# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1240925797 -7200 # Node ID 5cc3afa14e4b8df8720d6ad3097c0cd92b3521dd # Parent e25be3c82947336127b65b432bcc6e01b58c617e new match_transition selector diff -r e25be3c82947 -r 5cc3afa14e4b selectors.py --- a/selectors.py Tue Apr 28 15:36:04 2009 +0200 +++ b/selectors.py Tue Apr 28 15:36:37 2009 +0200 @@ -51,7 +51,8 @@ from yams import BASE_TYPES -from cubicweb import Unauthorized, NoSelectableObject, NotAnEntity, role +from cubicweb import (Unauthorized, NoSelectableObject, NotAnEntity, + role, typed_eid) from cubicweb.vregistry import (NoSelectableObject, Selector, chainall, objectify_selector) from cubicweb.cwconfig import CubicWebConfiguration @@ -529,6 +530,20 @@ return score +class match_transition(match_search_state): + @lltrace + def __call__(self, cls, req, rset=None, row=None, col=0, **kwargs): + try: + trname = req.execute('Any XN WHERE X is Transition, X eid %(x)s, X name XN', + {'x': typed_eid(req.form['treid'])})[0][0] + except (KeyError, IndexError): + return 0 + # XXX check this is a transition that apply to the object? + if not trname in self.expected: + return 0 + return 1 + + class match_view(match_search_state): """accept if the current view is in one of the expected vid given to the initializer