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 pylons-discuss@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to