45.2. EVENT TYPES
class ContextFound(request)
An instance of this class is emitted as an event after the Pyramid router finds a context object (after it performs traversal) but before any view code is executed. The instance has an attribute, request, which is the request object generated by Pyramid.
Notably, the request object will have an attribute named context, which is the context that will be provided to the view which will eventually be called, as well as other attributes attached by context-finding code.
This class implements the pyramid.interfaces.IContextFound interface.
latex-note.png
As of Pyramid 1.0, for backwards compatibility purposes, this event may also be imported as pyramid.events.AfterTraversal.
class NewResponse(request, response)
An instance of this class is emitted as an event whenever any Pyramid view or exception view returns a response.
The instance has two attributes:request, which is the request which caused the response, and response, which is the response object returned by a view or renderer.
If the response was generated by an exception view, the request will have an attribute named exception, which is the exception object which caused the exception view to be executed. If the response was generated by a ‘normal’ view, this attribute of the request will be None.
This event will not be generated if a response cannot be created due to an exception that is not caught by an exception view (no response is created under this circumstace).
This class implements the pyramid.interfaces.INewResponse interface.
|
|
|
|
|
|
latex-note.png |
|
|
|
|
|
|
Postprocessing a response is usually better |
han- |
dled |
in a |
WSGI |
middleware component than in subscriber code |
that |
is |
called |
by a |
pyramid.interfaces.INewResponse event. |
The |
pyramid.interfaces.INewResponse event exists almost purely for symmetry with the pyramid.interfaces.INewRequest event.