Sending mail and exception reports

47 views
Skip to first unread message

Mike Orr

unread,
Sep 29, 2015, 12:24:18 AM9/29/15
to pylons-...@googlegroups.com
I need to send email in my Pyramid application, and I'd like to set up
emailed exception reports like Pylons does.

I looked around and found 'pyramid_mailer' and 'pyramid_marrowmailer'.
Does anyone have any particular recommendations? I'll probably go with
'pyramid_mailer' because it looks more flexible: it can send a message
or save it to a debug directory or testing variables, either in
transaction or immediately. I may need immediate sending to tailor the
response ("Request sent" or "Try again later"). 'pyramid_marrowmailer'
says only works within a transaction.

I tried 'pyramid_mailer' and got it working in a test application,
although not yet to the point of switching modes seamlessly with just
a configuration change.

For emailed exceptions I found 'pyramid_errmail'
https://github.com/Pylons/pyramid_errmail
which uses 'pyramid_mailer', but it's not on PyPI, hasn't been updated
since Pyramid 1.2-dev (2011), has at least one major bug
('config.add_tween' now requires a dotted name, not a function
object), and I'm not sure if it's compatible with pyramid_mailer's
debug mode (it didn't write a file when I tried). However, I did get
it to email an HTML traceback, so at least that's something. Is anyone
using it, or is there anything better?

I also found 'pyramid_exclog', which logs exceptions to a Python
logger, which you can configure with an SMTP logging handler. But that
doesn't integrate with 'pyramid_mailer' or anything similar, so no
config settings or debug mode, which I'd like to have. Although it may
be the simplest and most foolproof code?

--
Mike Orr <slugg...@gmail.com>

David Glick (Glick Software)

unread,
Sep 29, 2015, 12:38:54 AM9/29/15
to pylons-...@googlegroups.com
You may also want to look at https://pypi.python.org/pypi/mailinglogger,
another Python logging handler. It doesn't solve the problems you
mentioned with using an SMTP logging handler, but it does handle rate
limiting which is nice when you've got a production system hitting a
repeated exception that you're already working on. It might be a good
starting point for creating a handler that integrates with
pyramid_mailer for the actual sending.

David

Jonathan Vanasco

unread,
Sep 29, 2015, 12:03:27 PM9/29/15
to pylons-discuss
We use pyramid_mailer and enjoy it.  We're a bit heavily invested into it though, because of some custom & approved patches + transaction support.

In terms of exception reporting -- we do exception logging into SQL via a custom tween. It's super simple code.  Logging into an immediate mail send would not be much more.  here's most of it cut out :  https://gist.github.com/jvanasco/8b23b628c77d9e18c71a

Tim Hoffman

unread,
Oct 3, 2015, 3:29:32 AM10/3/15
to pylons-discuss
I use sentry for this type of activity in a bunch of other projects, and am about to include it in my current pyramid project 

https://github.com/thruflo/pyramid_raven is the pyramid raven client for  sentry 

I like using sentry as a consolidation for all exceptions/loggable events, and then set specific rules for emails outside of the application.

T
Reply all
Reply to author
Forward
0 new messages