summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Petrello <lists@ryanpetrello.com>2015-01-08 14:00:33 -0500
committerRyan Petrello <lists@ryanpetrello.com>2015-01-08 14:58:16 -0500
commitfe19eb67a83c4ec1e239586b2d7a6141a5d56418 (patch)
tree6fec3a36f829c50451f60ab2d79ea6a680091c8d
parentfcfbd06ccceca449fa1703ab51fad4035f994525 (diff)
downloadpecan-fe19eb67a83c4ec1e239586b2d7a6141a5d56418.tar.gz
Document pecan.request.context
Fixes-bug: 1408755 Change-Id: Ie87a6b9e72fd1387e69db1b6f24d4475ecba56c6
-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
----------------