From 7e8efeb6e45c16b40bf479489c7016927242b2c7 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Fri, 13 Oct 2017 15:28:33 +0300 Subject: [PATCH] Fix misleading documentation IMO, you would normally interpret "creating and closing database connections all the time" as "creating and closing database connection on each request" as opposed to keeping persistent database connection for a lifetime of an application. However, the documentation is either misleading or "creating and closing database connection on each query" was implied. This, and the term "**application** context" itself makes it look like data placed into flask.g will be available for the following requests, which is not true at all. Let's make the documentation more explicit on this. --- docs/tutorial/dbcon.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/tutorial/dbcon.rst b/docs/tutorial/dbcon.rst index 179c962b..d4548716 100644 --- a/docs/tutorial/dbcon.rst +++ b/docs/tutorial/dbcon.rst @@ -8,11 +8,11 @@ Let's continue building our code in the ``flaskr.py`` file. You currently have a function for establishing a database connection with `connect_db`, but by itself, it is not particularly useful. Creating and -closing database connections all the time is very inefficient, so you will -need to keep it around for longer. Because database connections -encapsulate a transaction, you will need to make sure that only one -request at a time uses the connection. An elegant way to do this is by -utilizing the *application context*. +closing database connections for each query is very inefficient, so you +will need to keep it around for the duratiob of a request. Because database +connections encapsulate a transaction, you will need to make sure that +only one request at a time uses the connection. An elegant way to do this +is by utilizing the *application context*. Flask provides two contexts: the *application context* and the *request context*. For the time being, all you have to know is that there