Thanks Michael, adding a view for the Exception context worked perfectly. So, I did this in __init__.py:
from myapp.system import error_view config.add_view(error_view, renderer = 'templates/error_template.pt', context=Exception) Ben On 13 September 2011 23:41, Michael Merickel <[email protected]> wrote: > The way to think about this is that Pyramid is at the end of a WSGI > pipeline. It supports a way for catching and handling any exceptions that > occur within Pyramid itself via exception views. You have seen one exception > view already via the HTTPNotFound exception. You may add an exception view > for anything raised within Pyramid, including HTTPForbidden, > HTTPInternalServerError or even *Exception*. An exception view is invoked if > an exception of that type is *raised*. Thus for your HTTPInternalServerError > exception view to be invoked you'd need to "raise HTTPInternalServerError" > somewhere in your code. Obviously the general way to add a view for all > exceptions is to add a view for Exception, which uses your internal_error > template and sets the response's status to 500. You can then further add > more specific instances of Exception, like HTTPNotFound if you wanted a > different error template (or status code) for that exception. > > Note that exception views only work for exceptions, if you *return* > HTTPNotFound, the exception view will not be invoked and the returned value > will be expected to be a conforming Response object (which it happens to > be). > > Now, if an exception is not handled by Pyramid because you didn't add a > view for it, then it will simply propagate up the WSGI stack until something > else handled it. WebError is one such option. If left unhandled, the WSGI > server will catch it and return a default 500 page (which is what you're > seeing). > > Your INI setup is actually incorrect, because you didn't actually add the > filter to the pipeline. Configuring a filter is only one step, you also must > add it: > > [pipeline:main] > pipeline = > weberror > tm > myapp > > -- > > Michael > > -- > 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.
