aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/after.py
diff options
context:
space:
mode:
authorLei Yan2014-07-14 16:23:12 +0000
committerLei Yan2014-07-14 17:02:01 +0000
commit214bf0128b8ecdda718983c5563cf34160743758 (patch)
tree917e7a5ae78dc4ff65dc08d107a0e3ae3a47c67c /wqflask/utility/after.py
parent8de6fec18cd98a10c58702c448a1e01e147dc5f7 (diff)
parentfbdbf4b7410185e2a978ecc8e120ae56ff6da0ce (diff)
downloadgenenetwork2-214bf0128b8ecdda718983c5563cf34160743758.tar.gz
Merge /home/zas1024/gene
Conflicts: wqflask/wqflask/static/new/javascript/dataset_select_menu.js wqflask/wqflask/templates/corr_scatter_plot_old.html
Diffstat (limited to 'wqflask/utility/after.py')
-rwxr-xr-xwqflask/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 100755
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