[notification] don't block while sending mails
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 30 Mar 2015 11:47:43 +0200
changeset 10296 df34de44f40f
parent 10295 080ac14df6fa
child 10297 7f64859dcbcd
[notification] don't block while sending mails Regression from #7c17659c9eae, closes #5190001.
sobjects/notification.py
--- a/sobjects/notification.py	Sun Feb 01 22:17:25 2015 +0100
+++ b/sobjects/notification.py	Mon Mar 30 11:47:43 2015 +0200
@@ -81,7 +81,11 @@
     # this is usually the method to call
     def render_and_send(self, **kwargs):
         """generate and send email messages for this view"""
-        self._cw.vreg.config.sendmails(self.render_emails(**kwargs))
+        # render_emails changes self._cw so cache it here so all mails are sent
+        # after we commit our transaction.
+        cnx = self._cw
+        for msg, recipients in self.render_emails(**kwargs):
+            SendMailOp(cnx, recipients=recipients, msg=msg)
 
     def cell_call(self, row, col=0, **kwargs):
         self.w(self._cw._(self.content) % self.context(**kwargs))