You can either make it conditionally added using config.add_view in your
main function:
from pyramid.config import Configurator
from pyramid.settings import asbool
def main(global_config, **settings):
config = Configurator(settings=settings)
if asbool(settings.get('show_friendly_error_page)):
config.add_view(catch_500, context=Exception, renderer='templates/
500.pt')
return config.make_wsgi_app()
or you can make something that you add via pyramid.includes similar to the
debug bar. Knowing how to do that off the top of my head is above my pay
grade, but I am sure that you can look at either pyramid_debugtoolbar or
the pyramid_exclog to see how to do this. I *think* that you need to is
create a module with an includeme functionn as documented for
Configureator.include (
http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/api/config.html#pyramid.config.Configurator.include
).
-Chris
On Tue, May 8, 2012 at 10:23 AM, Brian Morgan <[email protected]> wrote:
> Please forgive me if this is documented somewhere or has been asked and
> answered before. I've been searching but haven't been able to find an
> answer.
>
> How do I get django-like error handling with Pyramid, where I can debug
> exceptions with the pyramid debugtoolbar during development, and in
> production send an email and display a nice error message? I've got it
> mostly working. The problem is that I've defined an error handling view
> like so:
>
> @view_config(context=Exception, renderer='templates/500.pt')
> def catch_500(request):
> response = request.response
> response.status_int = 500
> return {}
>
> And that works great with pyramid_exclog for sending the email. But when I
> try to run that in development with the pyramid_debugtoolbar included, the
> exception always gets handled by the view. The behaviour I'd like to see is
> for the debugtoolbar to catch the exception before it gets to the exception
> view. When I take out the view definition, the debugtoolbar _will_ catch
> it, so I know I've got the debugtoolbar included correctly. I'm sure this
> is not an unusual request, and I've got to be missing something obvious.
>
> Thanks for your help.
>
> -Brian
>
> --
> 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/-/ZnvEgdOxszoJ.
> 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.
>
--
Christopher Lambacher
[email protected]
--
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.