summaryrefslogtreecommitdiff
path: root/CHANGES.txt
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-07-24 01:39:54 -0400
committerChris McDonough <chrism@plope.com>2011-07-24 01:39:54 -0400
commit47525f0359bee8db346f5dbf774e4974c69fd2a9 (patch)
tree498b17355085eea61f72f9ba4e1e723cb17ddd39 /CHANGES.txt
parent6434998267a4930fd9175df06b9a07d83937b71d (diff)
parentdc45abfdfe1ec247ce199dcedeb178146a749023 (diff)
downloadpyramid-47525f0359bee8db346f5dbf774e4974c69fd2a9.tar.gz
pyramid-47525f0359bee8db346f5dbf774e4974c69fd2a9.tar.bz2
pyramid-47525f0359bee8db346f5dbf774e4974c69fd2a9.zip
fix merge conflicts
Diffstat (limited to 'CHANGES.txt')
-rw-r--r--CHANGES.txt58
1 files changed, 58 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 57ab76e46..c9c95fd7f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -8,6 +8,64 @@ Features
``rendering_val``. This can be used to introspect the value returned by a
view in a BeforeRender subscriber.
+- New configurator directive:
+ ``pyramid.config.Configurator.add_request_handler``. This directive adds
+ a request handler factory.
+
+ A request handler factory is used to wrap the Pyramid router's primary
+ request handling function. This is a feature may be used by framework
+ extensions, to provide, for example, view timing support and as a
+ convenient place to hang bookkeeping code that examines exceptions before
+ they are returned to the server.
+
+ A request handler factory (passed as ``handler_factory``) must be a
+ callable which accepts two arguments: ``handler`` and ``registry``.
+ ``handler`` will be the request handler being wrapped. ``registry`` will
+ be the Pyramid application registry represented by this Configurator. A
+ request handler factory must return a request handler when it is called.
+
+ A request handler accepts a request object and returns a response object.
+
+ Here's an example of creating both a handler factory and a handler, and
+ registering the handler factory:
+
+ .. code-block:: python
+
+ import time
+
+ def timing_handler_factory(handler, registry):
+ if registry.settings['do_timing']:
+ # if timing support is enabled, return a wrapper
+ def timing_handler(request):
+ start = time.time()
+ try:
+ response = handler(request)
+ finally:
+ end = time.time()
+ print: 'The request took %s seconds' % (end - start)
+ return response
+ return timing_handler
+ # if timing support is not enabled, return the original handler
+ return handler
+
+ config.add_request_handler(timing_handler_factory, 'timing')
+
+ The ``request`` argument to the handler will be the request created by
+ Pyramid's router when it receives a WSGI request.
+
+ If more than one request handler factory is registered into a single
+ configuration, the request handlers will be chained together. The first
+ request handler factory added (in code execution order) will be called with
+ the default Pyramid request handler, the second handler factory added will
+ be called with the result of the first handler factory, ad infinitum. The
+ Pyramid router will use the outermost wrapper in this chain (which is a bit
+ like a WSGI middleware "pipeline") as its handler function.
+
+ The ``name`` argument to this function is required. The name is used as a
+ key for conflict detection. No two request handler factories may share the
+ same name in the same configuration (unless automatic_conflict_resolution
+ is able to resolve the conflict or this is an autocommitting configurator).
+
1.1 (2011-07-22)
================