forked from orbit-oss/flask
Documented changes on the g object some more
This commit is contained in:
parent
1f6be7ff63
commit
93073489a0
3 changed files with 24 additions and 1 deletions
11
docs/api.rst
11
docs/api.rst
|
|
@ -272,7 +272,16 @@ thing, like it does for :class:`request` and :class:`session`.
|
|||
|
||||
Starting with Flask 0.10 this is stored on the application context and
|
||||
no longer on the request context which means it becomes available if
|
||||
only the application context is bound and not yet a request.
|
||||
only the application context is bound and not yet a request. This
|
||||
is especially useful when combined with the :ref:`faking-resources`
|
||||
pattern for testing.
|
||||
|
||||
Additionally as of 0.10 you can use the subscription operator syntax to
|
||||
get an attribute or `None` if it's not set. These two usages are now
|
||||
equivalent::
|
||||
|
||||
user = getattr(flask.g, 'user', None)
|
||||
user = flask.g['user']
|
||||
|
||||
This is a proxy. See :ref:`notes-on-proxies` for more information.
|
||||
|
||||
|
|
|
|||
|
|
@ -250,6 +250,7 @@ requires that you pass it a response object::
|
|||
This in general is less useful because at that point you can directly
|
||||
start using the test client.
|
||||
|
||||
.. _faking-resources:
|
||||
|
||||
Faking Resources and Context
|
||||
----------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue