Skip to content
Myr

enumerates the states in which code is executed...

Before adoption: this commit came in with the history the project adopted, so no landing records it.

... and fixes an awkward phrasing.

authored by Zev Averbach · committed by Zev Averbach · parent bbd6c8c · Browse files · 1 file+18 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+18 added−12 removed

  • other:+18 added−12 removed

1 file+18 added−12 removed

modified:docs/appcontext.rst+18 added-12 removed
3 unmodified lines
4=======================56.. versionadded:: 0.978One of the design ideas behind Flask is that there are two different9“states” in which code is executed. The application setup state in which10the application implicitly is on the module level. It starts when the11:class:`Flask` object is instantiated, and it implicitly ends when the12first request comes in. While the application is in this state a few13assumptions are true:8One of the design ideas behind Flask is that there are at least two 9different “states” in which code is executed:10111. The application setup state, in which the application implicitly is 12on the module level. 1314This state starts when the :class:`Flask` object is instantiated, and 15it implicitly ends when the first request comes in. While the 16application is in this state, a few assumptions are true:1718- the programmer can modify the application object safely.19- no request handling happened so far20- you have to have a reference to the application object in order to21 modify it, there is no magic proxy that can give you a reference to22 the application object you're currently creating or modifying.2321In contrast, during request handling, a couple of other rules exist:242. In contrast, in the request handling state, a couple of other rules 25exist:2627- while a request is active, the context local objects28 (:data:`flask.request` and others) point to the current request.29- any code can get hold of these objects at any time.3027There is a third state which is sitting in between a little bit.313. There is also a third state somewhere in between 'module-level' and 32'request-handling':3334Sometimes you are dealing with an application in a way that is similar to29how you interact with applications during request handling; just that there30is no request active. Consider, for instance, that you're sitting in an31interactive Python shell and interacting with the application, or a32command line application.35how you interact with applications during request handling, but without 36there being an active request. Consider, for instance, that you're 37sitting in an interactive Python shell and interacting with the 38application, or a command line application.3940The application context is what powers the :data:`~flask.current_app`41context local.42
102 unmodified lines