Updated the docs and examples to non-failing teardown handlers

This commit is contained in:
Armin Ronacher 2011-08-25 20:56:43 +01:00
parent 485a6c332b
commit d3ca55177a
5 changed files with 24 additions and 5 deletions

View file

@ -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('/')

View file

@ -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('/')