forked from orbit-oss/flask
Updated documentation to use teardown request where appropriate
This commit is contained in:
parent
ba6bf23e0d
commit
a9fc040c39
4 changed files with 45 additions and 40 deletions
|
|
@ -65,10 +65,9 @@ automatically remove database sessions at the end of the request for you::
|
|||
|
||||
from yourapplication.database import db_session
|
||||
|
||||
@app.after_request
|
||||
def shutdown_session(response):
|
||||
@app.teardown_request
|
||||
def shutdown_session(exception=None):
|
||||
db_session.remove()
|
||||
return response
|
||||
|
||||
Here is an example model (put this into `models.py`, e.g.)::
|
||||
|
||||
|
|
@ -140,10 +139,9 @@ each request. Put this into your application module::
|
|||
|
||||
from yourapplication.database import db_session
|
||||
|
||||
@app.after_request
|
||||
def shutdown_session(response):
|
||||
@app.teardown_request
|
||||
def shutdown_session(exception=None):
|
||||
db_session.remove()
|
||||
return response
|
||||
|
||||
Here is an example table and model (put this into `models.py`)::
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue