blob: a3bb85e948536d5d66298c28e69aeda955cf13bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
|