| | |
| | | import venusian |
| | | |
| | | from zope.interface import ( |
| | | implementer, |
| | | Interface |
| | | ) |
| | | from zope.interface import implementer, Interface |
| | | |
| | | from pyramid.interfaces import ( |
| | | IContextFound, |
| | |
| | | IApplicationCreated, |
| | | IBeforeRender, |
| | | IBeforeTraversal, |
| | | ) |
| | | ) |
| | | |
| | | |
| | | class subscriber(object): |
| | | """ Decorator activated via a :term:`scan` which treats the function |
| | |
| | | Added the ``_depth`` and ``_category`` arguments. |
| | | |
| | | """ |
| | | venusian = venusian # for unit testing |
| | | |
| | | venusian = venusian # for unit testing |
| | | |
| | | def __init__(self, *ifaces, **predicates): |
| | | self.ifaces = ifaces |
| | |
| | | config.add_subscriber(wrapped, iface, **self.predicates) |
| | | |
| | | def __call__(self, wrapped): |
| | | self.venusian.attach(wrapped, self.register, category=self.category, |
| | | depth=self.depth + 1) |
| | | self.venusian.attach( |
| | | wrapped, |
| | | self.register, |
| | | category=self.category, |
| | | depth=self.depth + 1, |
| | | ) |
| | | return wrapped |
| | | |
| | | |
| | | @implementer(INewRequest) |
| | | class NewRequest(object): |
| | |
| | | event instance has an attribute, ``request``, which is a |
| | | :term:`request` object. This event class implements the |
| | | :class:`pyramid.interfaces.INewRequest` interface.""" |
| | | |
| | | def __init__(self, request): |
| | | self.request = request |
| | | |
| | | |
| | | @implementer(INewResponse) |
| | | class NewResponse(object): |
| | |
| | | almost purely for symmetry with the |
| | | :class:`pyramid.interfaces.INewRequest` event. |
| | | """ |
| | | |
| | | def __init__(self, request, response): |
| | | self.request = request |
| | | self.response = response |
| | | |
| | | |
| | | @implementer(IBeforeTraversal) |
| | | class BeforeTraversal(object): |
| | |
| | | |
| | | def __init__(self, request): |
| | | self.request = request |
| | | |
| | | |
| | | @implementer(IContextFound) |
| | | class ContextFound(object): |
| | |
| | | As of :app:`Pyramid` 1.0, for backwards compatibility purposes, this |
| | | event may also be imported as :class:`pyramid.events.AfterTraversal`. |
| | | """ |
| | | |
| | | def __init__(self, request): |
| | | self.request = request |
| | | |
| | | AfterTraversal = ContextFound # b/c as of 1.0 |
| | | |
| | | AfterTraversal = ContextFound # b/c as of 1.0 |
| | | |
| | | |
| | | @implementer(IApplicationCreated) |
| | | class ApplicationCreated(object): |
| | |
| | | :class:`pyramid.events.WSGIApplicationCreatedEvent`. This was the name |
| | | of the event class before :app:`Pyramid` 1.0. |
| | | """ |
| | | |
| | | def __init__(self, app): |
| | | self.app = app |
| | | self.object = app |
| | | |
| | | WSGIApplicationCreatedEvent = ApplicationCreated # b/c (as of 1.0) |
| | | |
| | | WSGIApplicationCreatedEvent = ApplicationCreated # b/c (as of 1.0) |
| | | |
| | | |
| | | @implementer(IBeforeRender) |
| | | class BeforeRender(dict): |
| | |
| | | |
| | | See also :class:`pyramid.interfaces.IBeforeRender`. |
| | | """ |
| | | |
| | | def __init__(self, system, rendering_val=None): |
| | | dict.__init__(self, system) |
| | | self.rendering_val = rendering_val |
| | | |