aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2020-04-28 08:32:00 -0500
committerPjotr Prins2020-04-28 08:32:00 -0500
commit9ec149a6a7498fc812ed4a44fa85bb746475a253 (patch)
tree1a6e6972cac5ea6b0fd246e74d6a9de104291e75
parent0bca6569530d100291f176d04df8af9700705231 (diff)
downloadgenenetwork2-9ec149a6a7498fc812ed4a44fa85bb746475a253.tar.gz
Track requests and check for attribute so at least we get the right error:penguin2
GeneNetwork penguin2:genenetwork2:2.11-rc2-penguin2-0bca65695 http://gn2-test3.genenetwork.org/ ( 1:31PM UTC Apr 28, 2020) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. (error) File "/home/wrk/opt/genenetwork2/lib/python2.7/site-packages/redis/connection.py", line 717, in read_response
-rw-r--r--wqflask/wqflask/templates/base.html2
-rw-r--r--wqflask/wqflask/user_manager.py3
-rw-r--r--wqflask/wqflask/user_session.py21
-rw-r--r--wqflask/wqflask/views.py1
4 files changed, 18 insertions, 9 deletions
diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html
index 487cf3f2..abe14831 100644
--- a/wqflask/wqflask/templates/base.html
+++ b/wqflask/wqflask/templates/base.html
@@ -72,6 +72,7 @@
<li><a href="httP://datafiles.genenetwork.org">Interplanetary File System</a></li>
</ul>
</li>
+ {% if g.user_session %}
<li class="">
<a href="/collections/list">Collections
<span class="badge badge-info">{{ g.user_session.num_collections }}</span>
@@ -93,6 +94,7 @@
<a id="login_in" href="/n/login">Sign in</a>
{% endif %}
</li>
+ {% endif %}
<!--
<li style="margin-left: 20px;">
<a href="http://gn2-staging.genenetwork.org" style="font-weight: bold;" >Use Staging Branch</a>
diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py
index 1b27d7cb..ce76e0e8 100644
--- a/wqflask/wqflask/user_manager.py
+++ b/wqflask/wqflask/user_manager.py
@@ -351,7 +351,8 @@ class UserSession(object):
logger.debug("At end of delete_session")
@app.before_request
-def before_request():
+def get_cookie():
+ logger.info("@app.before_request get cookie")
g.user_session = UserSession()
g.cookie_session = AnonUser()
diff --git a/wqflask/wqflask/user_session.py b/wqflask/wqflask/user_session.py
index fd1779fb..4c2305ba 100644
--- a/wqflask/wqflask/user_session.py
+++ b/wqflask/wqflask/user_session.py
@@ -25,6 +25,19 @@ logger = getLogger(__name__)
THREE_DAYS = 60 * 60 * 24 * 3
THIRTY_DAYS = 60 * 60 * 24 * 30
+@app.before_request
+def get_user_session():
+ logger.info("@app.before_request get_session")
+ g.user_session = UserSession()
+
+@app.after_request
+def set_user_session(response):
+ if hasattr(g, 'user_session'):
+ if not request.cookies.get(g.user_session.cookie_name):
+ response.set_cookie(g.user_session.cookie_name, g.user_session.cookie)
+ return response
+
+
def verify_cookie(cookie):
the_uuid, separator, the_signature = cookie.partition(':')
assert len(the_uuid) == 36, "Is session_id a uuid?"
@@ -280,12 +293,4 @@ class UserSession(object):
Redis.delete(self.redis_key)
self.logged_in = False
-@app.before_request
-def before_request():
- g.user_session = UserSession()
-@app.after_request
-def set_cookie(response):
- if not request.cookies.get(g.user_session.cookie_name):
- response.set_cookie(g.user_session.cookie_name, g.user_session.cookie)
- return response \ No newline at end of file
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 76857650..ef295b5b 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -80,6 +80,7 @@ logger = utility.logger.getLogger(__name__ )
@app.before_request
def connect_db():
+ logger.info("@app.before_request connect_db")
db = getattr(g, '_database', None)
if db is None:
logger.debug("Get new database connector")