yes, i think send_to_queue would be better, because this allows to
retry sending the message.
regards
robert

On Thu, Jun 28, 2012 at 12:27 PM, Antonio Beamud Montero
<antonio.bea...@gmail.com> wrote:
> El 27/06/12 21:18, Jason escribió:
>
>
>
> On Wednesday, June 27, 2012 12:49:19 PM UTC-4, antonio wrote:
>>
>>
>>
>> The problem is the user data is commited to the database, but the mail
>> is not sent.
>> I want, if the mail cannot be sent, abort the transaction, rollback the
>> data flushed to the database and show a message to the user in a ordered
>> way...
>>
>> How I can do this?
>>
>> Greetings
>
>
> Then you will run into the problem of having the mail already sent out if
> the database transaction fails to commit.
>
>
> I've solved with the next code:
>     ...
>     try:
>         mailer = get_mailer(self.request)
>         message = Message(subject=subject,
>                           sender=sender,
>                           recipients=[user.email],
>                           body=body % confirm_url)
>         mailer.send_immediately(message)
>     except:
>         log.error('sending mail error')
>         transaction.doom()
>     ...
> Perhaps the best approach is use the send_to_queue, and not send the mail in
> the request.
>
> Greetings.
>
>
> -- Jason
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pylons-discuss/-/yaCyxfafY3QJ.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To unsubscribe from this group, send email to
> pylons-discuss+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To unsubscribe from this group, send email to
> pylons-discuss+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to