summaryrefslogtreecommitdiff
path: root/repoze/bfg/router.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2010-09-12 12:45:07 +0000
committerChris McDonough <chrism@agendaless.com>2010-09-12 12:45:07 +0000
commit8f45bee662176e1b2a850a4a9fe25d26b03093a6 (patch)
tree852a99ba184e1c1b24fb09197df2801372200541 /repoze/bfg/router.py
parent887a0c78919e6c3d1acfe1f9cc16a3aaf054a514 (diff)
downloadpyramid-8f45bee662176e1b2a850a4a9fe25d26b03093a6.tar.gz
pyramid-8f45bee662176e1b2a850a4a9fe25d26b03093a6.tar.bz2
pyramid-8f45bee662176e1b2a850a4a9fe25d26b03093a6.zip
- The BFG router now emits an additional event unconditionally at the
end of request processing: ``repoze.bfg.interfaces.IFinishedRequest``. This event is meant to be used when it is necessary to perform unconditional cleanup after request processing. See the ``repoze.bfg.events.FinishedRequest`` class documentation for more information. - The ``repoze.bfg.interfaces.IWSGIApplicationCreatedEvent`` event interface was renamed to ``repoze.bfg.interfaces.IApplicationCreated``. Likewise, the ``repoze.bfg.events.WSGIApplicationCreatedEvent`` class was renamed to ``repoze.bfg.events.ApplicationCreated``. The older aliases will continue to work indefinitely. - The ``repoze.bfg.interfaces.IAfterTraversal`` event interface was renamed to ``repoze.bfg.interfaces.IContextFound``. Likewise, the ``repoze.bfg.events.AfterTraveral`` class was renamed to ``repoze.bfg.events.ContextFound``. The older aliases will continue to work indefinitely.
Diffstat (limited to 'repoze/bfg/router.py')
-rw-r--r--repoze/bfg/router.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/repoze/bfg/router.py b/repoze/bfg/router.py
index f976dfea2..fb5120d2b 100644
--- a/repoze/bfg/router.py
+++ b/repoze/bfg/router.py
@@ -15,9 +15,10 @@ from repoze.bfg.interfaces import IView
from repoze.bfg.interfaces import IViewClassifier
from repoze.bfg.configuration import make_app # b/c import
-from repoze.bfg.events import AfterTraversal
+from repoze.bfg.events import ContextFound
from repoze.bfg.events import NewRequest
from repoze.bfg.events import NewResponse
+from repoze.bfg.events import FinishedRequest
from repoze.bfg.exceptions import NotFound
from repoze.bfg.request import Request
from repoze.bfg.threadlocal import manager
@@ -59,6 +60,7 @@ class Router(object):
manager = self.threadlocal_manager
threadlocals = {'registry':registry, 'request':None}
manager.push(threadlocals)
+ request = None
try:
# create the request
@@ -68,7 +70,6 @@ class Router(object):
attrs = request.__dict__
attrs['registry'] = registry
has_listeners and registry.notify(NewRequest(request))
-
request_iface = IRequest
try:
@@ -101,7 +102,7 @@ class Router(object):
tdict['traversed'], tdict['virtual_root'],
tdict['virtual_root_path'])
attrs.update(tdict)
- has_listeners and registry.notify(AfterTraversal(request))
+ has_listeners and registry.notify(ContextFound(request))
context_iface = providedBy(context)
view_callable = adapters.lookup(
(IViewClassifier, request_iface, context_iface),
@@ -164,5 +165,8 @@ class Router(object):
return app_iter
finally:
- manager.pop()
+ try:
+ has_listeners and registry.notify(FinishedRequest(request))
+ finally:
+ manager.pop()