summaryrefslogtreecommitdiff
path: root/docs/narr/hooks.rst
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2014-08-06 11:59:45 -0500
committerMichael Merickel <michael@merickel.org>2014-08-06 11:59:45 -0500
commit9279468d0e4d411652a735e28839bd8a5504ced6 (patch)
tree580c1efc1044325a20a242a212d647b81cde6088 /docs/narr/hooks.rst
parent407b335ed9954c042377fd2e060c36edcd07cf60 (diff)
parent3587a53dc28b8f6411816ccd7fd8fdee0d88acb4 (diff)
downloadpyramid-9279468d0e4d411652a735e28839bd8a5504ced6.tar.gz
pyramid-9279468d0e4d411652a735e28839bd8a5504ced6.tar.bz2
pyramid-9279468d0e4d411652a735e28839bd8a5504ced6.zip
Merge branch 'master' into feature.override-asset-with-absolute-path
Diffstat (limited to 'docs/narr/hooks.rst')
-rw-r--r--docs/narr/hooks.rst8
1 files changed, 6 insertions, 2 deletions
diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst
index f2542f1d7..4da36e730 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.
@@ -1023,7 +1023,7 @@ method:
:linenos:
class simple_tween_factory(object):
- def __init__(handler, registry):
+ def __init__(self, handler, registry):
self.handler = handler
self.registry = registry
@@ -1040,6 +1040,10 @@ method:
return response
+You should avoid mutating any state on the tween instance. The tween is
+invoked once per request and any shared mutable state needs to be carefully
+handled to avoid any race conditions.
+
The closure style performs slightly better and enables you to conditionally
omit the tween from the request processing pipeline (see the following timing
tween example), whereas the class style makes it easier to have shared mutable