[Cubicweb] Workflows and Hooks

Sylvain Thénault sylvain.thenault at logilab.fr
Wed Aug 1 15:42:55 CEST 2012

On 01 août 11:37, Aurélien Campéas wrote:
> Le 01/08/2012 11:17, Stéphane Bugat a écrit :
> >I'm trying to capture the moment when a workflow changes its status to perform a relation creation.
> That leaves at least another way using wf_info_for (as an exercice ;-)
And this is the way I promote, because that's the place where you've
all the information you may need (from which state, to which state, using
which transition, etc). So you've to catch creation of TrInfo entities, and
there is a dedicated selector to help here :

class TransitionFiredHook(hook.Hook):
    __regid__ = 'myhook'
    __select__ = hook.Hook.__select__ & on_fire_transition('SearchedEntityType', 'transition name')
    events = ('after_add_entity',)

    def __call__(self):
        print self.entity # the TrInfo entity
        print self.entity.for_entity # the SearchEntityType entity

Sylvain Thénault, LOGILAB, Paris ( - Toulouse (
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org

More information about the Cubicweb mailing list