Notify multiple times custom event to send email not working

66 views Asked by At

Having obj = the object that was modified and SendNotificationEvent a custom event I'm trying to notify the custom event something like:

for email in emails:
    notify(SendNotificationEvent(obj, email))

I have a custom content rule with send email action that sends the message on SendNotificationEvent.

The problem is a single message is sent. The first one. It seems notify is working a single time. Do you have any idea how to investigate and fix this issue?

I already tried with debugger here and it seems I can notify the event for other objects and the email is sent, but for each different obj a single one then nothing happens.

1

There are 1 answers

0
GhitaB On BEST ANSWER

This commit was very useful. (Thank you, David, for nice description! Thank you, GitHub, for search feature.)

So, the solution is:

from plone.app.contentrules.handlers import close

for email in emails:
    evt = SendNotificationEvent(obj, email)
    notify(evt)
    close(evt)  # make sure it will work for multiple notify(