forked from orbit-oss/flask
Updated the docs and examples to non-failing teardown handlers
This commit is contained in:
parent
485a6c332b
commit
d3ca55177a
5 changed files with 24 additions and 5 deletions
|
|
@ -50,7 +50,8 @@ def before_request():
|
|||
@app.teardown_request
|
||||
def teardown_request(exception):
|
||||
"""Closes the database again at the end of the request."""
|
||||
g.db.close()
|
||||
if hasattr(g, 'db'):
|
||||
g.db.close()
|
||||
|
||||
|
||||
@app.route('/')
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ def before_request():
|
|||
@app.teardown_request
|
||||
def teardown_request(exception):
|
||||
"""Closes the database again at the end of the request."""
|
||||
g.db.close()
|
||||
if hasattr(g, 'db'):
|
||||
g.db.close()
|
||||
|
||||
|
||||
@app.route('/')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue