aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorZachary Sloan2014-02-27 00:01:11 +0000
committerZachary Sloan2014-02-27 00:01:11 +0000
commitdd6e828ca3b205fefcae833aec53139961f9575f (patch)
treecedc3363c8003b25a8407502d4e5efaf6ccae48e /wqflask/utility
parentb1fd0e00050ef7ba95fd077fb78773265629fb1b (diff)
downloadgenenetwork2-dd6e828ca3b205fefcae833aec53139961f9575f.tar.gz
Began working on a TraitCollection.py file that will contain both the
object for logged in user collections and collections created by anonymous users.
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/after.py22
1 files changed, 22 insertions, 0 deletions
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