# HG changeset patch # User Sylvain Thénault # Date 1400705686 -7200 # Node ID 7c17659c9eaefec1ec5c9568f8b9ef64acbc4f44 # Parent 946b483bc8a181259d61081b32b6d866af2e8dcf [notification] drop on commit sending of message feature of NotificationView It duplicates feature already provided by cw.hooks.notification.notify_on_commit function. Simplify the API on the way. diff -r 946b483bc8a1 -r 7c17659c9eae sobjects/notification.py --- a/sobjects/notification.py Fri Mar 21 08:28:32 2014 +0100 +++ b/sobjects/notification.py Wed May 21 22:54:46 2014 +0200 @@ -80,15 +80,8 @@ # this is usually the method to call def render_and_send(self, **kwargs): - """generate and send an email message for this view""" - delayed = kwargs.pop('delay_to_commit', None) - for recipients, msg in self.render_emails(**kwargs): - if delayed is None: - self.send(recipients, msg) - elif delayed: - self.send_on_commit(recipients, msg) - else: - self.send_now(recipients, msg) + """generate and send email messages for this view""" + self._cw.vreg.config.sendmails(self.render_emails(**kwargs)) def cell_call(self, row, col=0, **kwargs): self.w(self._cw._(self.content) % self.context(**kwargs)) @@ -146,16 +139,11 @@ continue msg = format_mail(self.user_data, [emailaddr], content, subject, config=self._cw.vreg.config, msgid=msgid, references=refs) - yield [emailaddr], msg + yield msg, [emailaddr] finally: - # ensure we have a cnxset since commit will fail if there is - # some operation but no cnxset. This may occurs in this very - # specific case (eg SendMailOp) - with cnx.ensure_cnx_set: - cnx.commit() self._cw = req - # recipients / email sending ############################################### + # recipients handling ###################################################### def recipients(self): """return a list of either 2-uple (email, language) or user entity to @@ -166,13 +154,6 @@ row=self.cw_row or 0, col=self.cw_col or 0) return finder.recipients() - def send_now(self, recipients, msg): - self._cw.vreg.config.sendmails([(msg, recipients)]) - - def send_on_commit(self, recipients, msg): - SendMailOp(self._cw, recipients=recipients, msg=msg) - send = send_on_commit - # email generation helpers ################################################# def construct_message_id(self, eid):