El 09/06/12 07:52, Michael Merickel escribió:
mailer.send() does not send immediately. As per the docs it uses the
transaction manager and sends the mail at the end of the request. You
can create an exception view for this exception, or call
mailer.send_immediately() instead. The transaction manager helps to
avoid sending emails when you get an exception in some part of your
code.
I have the same problem, in my case is managing a register form. The
user fill the form, the system processes the data and send a mail to
that user to confirm the data.
In my case, (I'm using pyramid_tm and pyramid_mailer), if the smtp
server is down, a exeception is raised and I cannot handle it:
2012-06-27 18:06:50,990 CRITI [txn.-1247151296][Dummy-2] A storage error
occurred during the second phase of the two-phase commit. Resources may
be in an inconsistent state.
2012-06-27 18:06:50,990 ERROR [txn.-1247151296][Dummy-2] Error in
tpc_abort() on manager <zope.sqlalchemy.datamanager.SessionDataManager
object at 0xb332c0ac>
...
File "/usr/lib/python2.7/smtplib.py", line 284, in _get_socket
return socket.create_connection((port, host), timeout)
File "/usr/lib/python2.7/socket.py", line 571, in create_connection
raise err
error: [Errno 111] Connection refused
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
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.