diff options
-rw-r--r-- | wqflask/base/trait_collection.py | 27 | ||||
-rw-r--r-- | wqflask/utility/after.py | 22 | ||||
-rw-r--r-- | wqflask/wqflask/collect.py | 2 | ||||
-rw-r--r-- | wqflask/wqflask/model.py | 6 |
4 files changed, 56 insertions, 1 deletions
diff --git a/wqflask/base/trait_collection.py b/wqflask/base/trait_collection.py new file mode 100644 index 00000000..797a4d63 --- /dev/null +++ b/wqflask/base/trait_collection.py @@ -0,0 +1,27 @@ +#The TraitCollection class with encompass the UserCollection (collections
+#created by registered and logged in users) and AnonCollection (collections created by users who
+#aren't logged in) class. The former will represent and act on a database table while the latter
+#will store its trait information in Redis
+
+
+from __future__ import print_function, division, absolute_import
+
+import uuid
+import datetime
+
+import simplejson as json
+
+from flask import request
+from flask.ext.sqlalchemy import SQLAlchemy
+
+from wqflask import app
+
+import sqlalchemy
+
+from sqlalchemy import (Column, Integer, String, Table, ForeignKey, Unicode, Boolean, DateTime,
+ Text, Index)
+from sqlalchemy.orm import relationship, backref
+
+from wqflask.database import Base, init_db
+
+class TraitCollection(object):
diff --git a/wqflask/utility/after.py b/wqflask/utility/after.py new file mode 100644 index 00000000..a3bb85e9 --- /dev/null +++ b/wqflask/utility/after.py @@ -0,0 +1,22 @@ +from __future__ import print_function, division, absolute_import + +""" +See: http://flask.pocoo.org/docs/patterns/deferredcallbacks/#deferred-callbacks + +""" + +from flask import g + +from wqflask import app + +def after_this_request(f): + if not hasattr(g, 'after_request_callbacks'): + g.after_request_callbacks = [] + g.after_request_callbacks.append(f) + return f + +@app.after_request +def call_after_request_callbacks(response): + for callback in getattr(g, 'after_request_callbacks', ()): + callback(response) + return response diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index 5a68c7c9..daa3b2af 100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -237,7 +237,7 @@ def view_collection(): traits = json.loads(uc.members) else: anon_id = params['key'] - uc = model.AnonCollection + uc = model.AnonCollection(anon_id = anon_id) traits = Redis.smembers(anon_id) print("the traits are:", traits) diff --git a/wqflask/wqflask/model.py b/wqflask/wqflask/model.py index 71bda550..fa8c1aab 100644 --- a/wqflask/wqflask/model.py +++ b/wqflask/wqflask/model.py @@ -189,3 +189,9 @@ def display_collapsible(number): return number else: return "" + + +def user_uuid(): + """Unique cookie for a user""" + user_uuid = request.cookies.get('user_uuid') +
\ No newline at end of file |