forked from orbit-oss/flask
request_init -> before_request and request_shutdown -> after_request
This fixes #9.
This commit is contained in:
parent
7b5015010b
commit
fb2d2e446b
6 changed files with 30 additions and 29 deletions
|
|
@ -41,13 +41,13 @@ def init_db():
|
|||
db.commit()
|
||||
|
||||
|
||||
@app.request_init
|
||||
@app.before_request
|
||||
def before_request():
|
||||
"""Make sure we are connected to the database each request."""
|
||||
g.db = connect_db()
|
||||
|
||||
|
||||
@app.request_shutdown
|
||||
@app.after_request
|
||||
def after_request(response):
|
||||
"""Closes the database again at the end of the request."""
|
||||
g.db.close()
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ def gravatar_url(email, size=80):
|
|||
(md5(email.strip().lower().encode('utf-8')).hexdigest(), size)
|
||||
|
||||
|
||||
@app.request_init
|
||||
@app.before_request
|
||||
def before_request():
|
||||
"""Make sure we are connected to the database each request and look
|
||||
up the current user so that we know he's there.
|
||||
|
|
@ -81,7 +81,7 @@ def before_request():
|
|||
[session['user_id']], one=True)
|
||||
|
||||
|
||||
@app.request_shutdown
|
||||
@app.after_request
|
||||
def after_request(response):
|
||||
"""Closes the database again at the end of the request."""
|
||||
g.db.close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue