aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wqflask/wqflask/views.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 10e53e5e..bce1f755 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -26,9 +26,10 @@ import base64
import array
import sqlalchemy
from wqflask import app
-from flask import (render_template, request, make_response, Response,
- Flask, g, config, jsonify, redirect, url_for,
- send_from_directory)
+from flask import g, request, render_template
+# from flask import (render_template, request, make_response, Response,
+# Flask, g, config, jsonify, redirect, url_for,
+# send_from_directory)
from wqflask import search_results
from wqflask import gsearch
from wqflask import update_search_results
@@ -73,8 +74,11 @@ def connect_db():
@app.teardown_appcontext
def shutdown_session(exception=None):
- logger.debug("remove db_session")
- db_session.remove()
+ db = getattr(g, '_database', None)
+ if db is not None:
+ logger.debug("remove db_session")
+ db_session.remove()
+ g.db = None
#@app.before_request
#def trace_it():