Browse Source

Updated docs for the app context.

pull/483/head
Armin Ronacher 13 years ago
parent
commit
0207e90155
  1. 3
      CHANGES
  2. 16
      docs/api.rst
  3. 10
      flask/ctx.py

3
CHANGES

@ -45,6 +45,9 @@ Relase date to be decided, codename to be chosen.
- The :meth:`flask.render_template` method now accepts a either an iterable of
template names or a single template name. Previously, it only accepted a
single template name. On an iterable, the first template found is rendered.
- Added :meth:`flask.Flask.app_context` which works very similar to the
request context but only provides access to the current application. This
also adds support for URL generation without an active request context.
Version 0.8.1

16
docs/api.rst

@ -265,12 +265,16 @@ Useful Functions and Classes
Points to the application handling the request. This is useful for
extensions that want to support multiple applications running side
by side.
by side. This is powered by the application context and not by the
request context, so you can change the value of this proxy by
using the :meth:`~flask.Flask.app_context` method.
This is a proxy. See :ref:`notes-on-proxies` for more information.
.. autofunction:: has_request_context
.. autofunction:: has_app_context
.. autofunction:: url_for
.. function:: abort(code)
@ -412,6 +416,16 @@ Useful Internals
if ctx is not None:
return ctx.session
.. autoclass:: flask.ctx.AppContext
:members:
.. data:: _app_ctx_stack
Works similar to the request context but only binds the application.
This is mainly there for extensions to store data.
.. versionadded:: 0.9
.. autoclass:: flask.blueprints.BlueprintSetupState
:members:

10
flask/ctx.py

@ -59,6 +59,16 @@ def has_request_context():
return _request_ctx_stack.top is not None
def has_app_context():
"""Worksl ike :func:`has_request_context` but for the application
context. You can also just do a boolean check on the
:data:`current_app` object instead.
.. versionadded:: 0.9
"""
return _app_ctx_stack.top is not None
class AppContext(object):
"""The application context binds an application object implicitly
to the current thread or greenlet, similar to how the

Loading…
Cancel
Save