From faaebc304a29308a98b22d8fc56c500b018b6c90 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 29 Aug 2008 18:48:48 +0000 Subject: Rejigger and document wsgi app created event. --- docs/api/events.rst | 2 ++ repoze/bfg/events.py | 11 +++++++++++ repoze/bfg/interfaces.py | 6 ------ repoze/bfg/router.py | 3 ++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/api/events.rst b/docs/api/events.rst index b2cd4a100..bb1ba1cf5 100644 --- a/docs/api/events.rst +++ b/docs/api/events.rst @@ -9,6 +9,8 @@ .. autoclass:: NewResponse + .. autoclass:: WSGIApplicationCreatedEvent + See :ref:`events_chapter` for more information about how to register code which subscribes to these events. diff --git a/repoze/bfg/events.py b/repoze/bfg/events.py index 3253f1380..b43fd5753 100644 --- a/repoze/bfg/events.py +++ b/repoze/bfg/events.py @@ -2,6 +2,7 @@ from zope.interface import implements from repoze.bfg.interfaces import INewRequest from repoze.bfg.interfaces import INewResponse +from repoze.bfg.interfaces import IWSGIApplicationCreatedEvent class NewRequest(object): """ An instance of this class is emitted as an event whenever @@ -21,3 +22,13 @@ class NewResponse(object): implements(INewResponse) def __init__(self, response): self.response = response + +class WSGIApplicationCreatedEvent(object): + """ An instance of this class is emitted as an event whenever a + ``repoze.bfg`` application starts. The instance has an attribute, + ``app``, which is an instance of the ``repoze.bfg.router.Router`` + class that will handle WSGI requests. This class implements the + ``repoze.bfg.interfaces.IWSGIApplicationCreatedEvent`` interface.""" + implements(IWSGIApplicationCreatedEvent) + def __init__(self, app): + self.app = app diff --git a/repoze/bfg/interfaces.py b/repoze/bfg/interfaces.py index d1a8fc63a..db2d1622d 100644 --- a/repoze/bfg/interfaces.py +++ b/repoze/bfg/interfaces.py @@ -92,9 +92,3 @@ class IWSGIApplicationCreatedEvent(IObjectEvent): configured.""" app = Attribute(u"Published application") - -class WSGIApplicationCreatedEvent(object): - implements(IWSGIApplicationCreatedEvent) - - def __init__(self, app): - self.app = app diff --git a/repoze/bfg/router.py b/repoze/bfg/router.py index 32e5b4b4d..3b4d16d8e 100644 --- a/repoze/bfg/router.py +++ b/repoze/bfg/router.py @@ -10,12 +10,13 @@ from webob.exc import HTTPUnauthorized from repoze.bfg.events import NewRequest from repoze.bfg.events import NewResponse +from repoze.bfg.events import WSGIApplicationCreatedEvent + from repoze.bfg.interfaces import ITraverserFactory from repoze.bfg.interfaces import IView from repoze.bfg.interfaces import IViewPermission from repoze.bfg.interfaces import ISecurityPolicy from repoze.bfg.interfaces import IRequest -from repoze.bfg.interfaces import WSGIApplicationCreatedEvent from repoze.bfg.registry import registry_manager -- cgit v1.2.3