Navigation

Decorator activated via a scan which treats the function
being decorated as an event subscriber for the set of interfaces passed
as *ifaces and the set of predicate terms passed as **predicates
to the decorator constructor.

An instance of this class is emitted as an event
whenever Pyramid begins to process a new request. The
event instance has an attribute, request, which is a
request object. This event class implements the
pyramid.interfaces.INewRequest interface.

An instance of this class is emitted as an event after
the Pyramidrouter 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.

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).

Subscribers to this event may introspect and modify the set of
renderer globals before they are passed to a renderer.
This event object iself has a dictionary-like interface that can be used
for this purpose. For example:

If a subscriber adds a key via __setitem__ that already exists in
the renderer globals dictionary, it will overwrite the older value there.
This can be problematic because event subscribers to the BeforeRender
event do not possess any relative ordering. For maximum interoperability
with other third-party subscribers, if you write an event subscriber meant
to be used as a BeforeRender subscriber, your subscriber code will need to
ensure no value already exists in the renderer globals dictionary before
setting an overriding value (which can be done using .get or
__contains__ of the event object).

The dictionary returned from the view is accessible through the
rendering_val attribute of a BeforeRender
event.

Suppose you return {'mykey':'somevalue','mykey2':'somevalue2'} from
your view callable, like so:

rendering_val can be used to access these values from the
BeforeRender object:

frompyramid.eventsimportsubscriberfrompyramid.eventsimportBeforeRender@subscriber(BeforeRender)defread_return(event):# {'mykey': 'somevalue'} is returned from the viewprint(event.rendering_val['mykey'])

In other words, rendering_val is the (non-system) value returned by a
view or passed to render* as value. This feature is new in Pyramid
1.2.

Update D from dict/iterable E and F. If E has a .keys() method, does:
for k in E: D[k] = E[k] If E lacks .keys() method, does: for (k, v) in
E: D[k] = v. In either case, this is followed by: for k in F: D[k] =
F[k].