Publish trigger

Hello all,
So I needed to tag some action to the publish trigger (or whatever it is called is Senaite). Any advice on where to start such an effort?

Hi @sufrjo , if you want to run your own logic when the action “publish” takes place for a given object, you can add an AfterTransitionEvent in your add-on to intercept the transition and call your code from there. To do so for when a Sample gets transitioned to “published”, you need to declare the subscriber, e.g:

  <!-- After event handler for Analysis Requests (aka Samples) -->
    handler=".analysisrequest.AfterTransitionEventHandler" />

and implement it, e.g.:

def AfterTransitionEventHandler(sample, event):
    """Actions to be done when a transition for sample takes place
    if event.transition and == "publish":
        # Do something here

Alternatively (not recommended), you could “HACK” with your code the after_publish event here:

1 Like