diff options
| author | Michael Merickel <michael@merickel.org> | 2014-05-21 11:03:37 -0500 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2014-05-21 11:03:37 -0500 |
| commit | b9ac2c34f23a2701f85471b605b00fba52e9b5cd (patch) | |
| tree | 787c03be2865feade31294c57a3e868fd558e0b0 /docs | |
| parent | dc9c386fb762defd97313cb6261fcd95f7321e71 (diff) | |
| parent | bf669af7f10ec81280fd8dbee43e414fa75457c5 (diff) | |
| download | pyramid-b9ac2c34f23a2701f85471b605b00fba52e9b5cd.tar.gz pyramid-b9ac2c34f23a2701f85471b605b00fba52e9b5cd.tar.bz2 pyramid-b9ac2c34f23a2701f85471b605b00fba52e9b5cd.zip | |
Merge branch 'pull.1349'
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/narr/hooks.rst | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst index 94be31bbc..fe7749cac 100644 --- a/docs/narr/hooks.rst +++ b/docs/narr/hooks.rst @@ -985,7 +985,7 @@ Creating a Tween To create a tween, you must write a "tween factory". A tween factory must be a globally importable callable which accepts two arguments: -``handler`` and ``registry``. ``handler`` will be the either the main +``handler`` and ``registry``. ``handler`` will be either the main Pyramid request handling function or another tween. ``registry`` will be the Pyramid :term:`application registry` represented by this Configurator. A tween factory must return the tween (a callable object) when it is called. @@ -995,6 +995,11 @@ A tween is called with a single argument, ``request``, which is the A tween should return a :term:`response`, usually the one generated by the downstream Pyramid application. +The tween factory will be shared between requests and is used to create one +tween per-request. Shared mutable state on the factory itself needs to be +carefully handled, and should be avoided unless you are willing to handle +the race conditions that may arise. + You can write the tween factory as a simple closure-returning function: .. code-block:: python |
