summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-01-09 19:34:34 +0000
committerGerrit Code Review <review@openstack.org>2015-01-09 19:34:34 +0000
commit62871d2d348558e87011c4a1f00cb244b90a5d8e (patch)
treeb6233e6e79596e4b809980831928a664df9a2656
parent868ab86e7666eea619c5371fe2b32f88d442c9a1 (diff)
parentfe19eb67a83c4ec1e239586b2d7a6141a5d56418 (diff)
downloadpecan-62871d2d348558e87011c4a1f00cb244b90a5d8e.tar.gz
Merge "Document pecan.request.context"
-rw-r--r--docs/source/routing.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/source/routing.rst b/docs/source/routing.rst
index 4b80472..80deca5 100644
--- a/docs/source/routing.rst
+++ b/docs/source/routing.rst
@@ -453,6 +453,25 @@ application's controller:
assert isinstance(request.POST['file'], cgi.FieldStorage)
data = request.POST['file'].file.read()
+Thread-Safe Per-Request Storage
+-------------------------------
+
+For convenience, Pecan provides a Python dictionary on every request which can
+be accessed and modified in a thread-safe manner throughout the life-cycle of
+an individual request::
+
+ pecan.request.context['current_user'] = some_user
+ print pecan.request.context.items()
+
+This is particularly useful in situations where you want to store
+metadata/context about a request (e.g., in middleware, or per-routing hooks)
+and access it later (e.g., in controller code).
+
+For more fine-grained control of the request, the underlying WSGI environ for
+a given Pecan request can be accessed and modified via
+``pecan.request.environ``.
+
+
Helper Functions
----------------