From 9373a71c263a63eca3c466cbc5b175ed5d4999d5 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Tue, 29 Jun 2010 15:25:20 +0200 Subject: [PATCH] improved _request_ctx_stack docs --- docs/api.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/api.rst b/docs/api.rst index fc6f68fb..4c45c2dd 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -301,6 +301,36 @@ Useful Internals instance and can be used by extensions and application code but the use is discouraged in general. + The following attributes are always present on each layer of the + stack:: + + `app` + the active Flask application. + + `url_adapter` + the URL adapter that was used to match the request. + + `request` + the current request object. + + `session` + the active session object. + + `g` + an object with all the attributes of the :data:`flask.g` object. + + `flashes` + an internal cache for the flashed messages. + + Example usage:: + + from flask import _request_ctx_stack + + def get_session(): + ctx = _request_ctx_stack.top + if ctx is not None: + return ctx.session + .. versionchanged:: 0.4 The request context is automatically popped at the end of the request