forked from 3wordchant/capsul-flask
fine-tuning and starting to work on account-balance
This commit is contained in:
@ -108,7 +108,7 @@ def init_app(app):
|
||||
|
||||
|
||||
def get_model():
|
||||
if 'model' not in g:
|
||||
if 'db_model' not in g:
|
||||
connection = current_app.config['PSYCOPG2_CONNECTION_POOL'].getconn()
|
||||
cursor = connection.cursor()
|
||||
g.db_model = DBModel(connection, cursor)
|
||||
@ -116,11 +116,11 @@ def get_model():
|
||||
|
||||
|
||||
def close_db(e=None):
|
||||
model = g.pop("model", None)
|
||||
db_model = g.pop("db_model", None)
|
||||
|
||||
if model is not None:
|
||||
model.cursor.close()
|
||||
current_app.config['PSYCOPG2_CONNECTION_POOL'].putconn(model.connection)
|
||||
if db_model is not None:
|
||||
db_model.cursor.close()
|
||||
current_app.config['PSYCOPG2_CONNECTION_POOL'].putconn(db_model.connection)
|
||||
|
||||
def my_exec_info_message(exec_info):
|
||||
return "{}: {}".format(".".join([exec_info[0].__module__, exec_info[0].__name__]), exec_info[1])
|
Reference in New Issue
Block a user