Skip to content
Myr

some grammar fixes in appcontext

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

* "in lack of" -> "for lack of" * pillar's -> pillars * ~~however~~ * a touch of cleanup to the "two ways" paragraph * ~~on there~~ * "database connects" -> "database connections"

authored by Bill Mill · committed by Bill Mill · parent c6795eb · Browse files · 1 file+12 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+12 added−12 removed

  • other:+12 added−12 removed

1 file+12 added−12 removed

modified:docs/appcontext.rst+12 added-12 removed
36 unmodified lines
37Purpose of the Application Context38----------------------------------3940The main reason for the application's context existence is that in the41past a bunch of functionality was attached to the request context in lack42of a better solution. Since one of the pillar's of Flask's design is that41past a bunch of functionality was attached to the request context for lack42of a better solution. Since one of the pillars of Flask's design is that43you can have more than one application in the same Python process.4445So how does the code find the “right” application? In the past we46recommended passing applications around explicitly, but that caused issues47with libraries that were not designed with that in mind.4849A common workaround for that problem was to use the50:data:`~flask.current_app` proxy later on, which was bound to the current51request's application reference. Since however creating such a request52context is an unnecessarily expensive operation in case there is no53request around, the application context was introduced.51request's application reference. Since creating such a request context is52an unnecessarily expensive operation in case there is no request around,53the application context was introduced.5455Creating an Application Context56-------------------------------5758To make an application context there are two ways. The first one is the59implicit one: whenever a request context is pushed, an application context60will be created alongside if this is necessary. As a result of that, you61can ignore the existence of the application context unless you need it.58There are two ways to make an application context. The first one is59implicit: whenever a request context is pushed, an application context60will be created alongside if this is necessary. As a result, you can61ignore the existence of the application context unless you need it.6263The second way is the explicit way using the64:meth:`~flask.Flask.app_context` method::65
24 unmodified lines
9091Context Usage92-------------9394The context is typically used to cache resources on there that need to be95created on a per-request or usage case. For instance database connects96are destined to go there. When storing things on the application context94The context is typically used to cache resources that need to be created95on a per-request or usage case. For instance, database connections are96destined to go there. When storing things on the application context97unique names should be chosen as this is a place that is shared between98Flask applications and extensions.99100The most common usage is to split resource management into two parts:
33 unmodified lines