Thanks Chris, that works great.
Sorry for the follow on question, but is there a similar way to handle
Python errors/500?
I have set up pyramid_exclog to send any errors to me by email. I also have
the following lines in my ini:
[pipeline:main]
pipeline =
tm
myapp
[filter:weberror]
use = egg:WebError#error_catcher
debug = false
I now get a correct 500 error and a message saying 'Internal Server Error'.
However, I would like to customise that error so that it works in a similar
way to the 404.
I tried adding this to the __init__:
from pyramid.httpexceptions import HTTPInternalServerError
from myapp.system import internal_error_view
config.add_view(internal_error_view, renderer = 'templates/
internal_error.pt',
context=HTTPInternalServerError)
However, this does not work (which as I understand it makes sense, since the
above indicates that the error has already gone out to paster).
Is there a catch-all way to catch the errors in Pyramid and use a fancy
error page?
Thanks,
Ben
On 13 September 2011 15:21, Chris McDonough <[email protected]> wrote:
> On Tue, 2011-09-13 at 15:05 +0100, Benjamin Sims wrote:
> > Hi,
> >
> > I'm trying to generate a custom 404 view for my application. I've
> > read:
> >
> >
> https://pylonsproject.org/projects/pyramid/dev/narr/hooks.html#changing-the-notfound-view
> >
> > However, I want to be able to have the 404 use a Chameleon template
> > with macros and so forth in order to fit in with the overall look and
> > feel.
> >
> > I have:
> >
> > config.add_view(notfound_view, renderer =
> > 'templates/view_not_found.pt', context=HTTPNotFound)
> >
> > in the __init__, and:
> >
> > def notfound_view(request):
> > master =
> > get_renderer('templates/macros_template.pt').implementation()
> > return dict(master = master)
>
>
> def notfound_view(request):
> request.response.status_int = 404
> master get_renderer('templates/macros_template.pt').implementation()
> return dict(master = master)
>
> It's slightly different in 1.0, but the above works in 1.1 and 1.2.
>
> - C
>
>
> --
> 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.
>
>
--
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.