From 2c59dcacc2163ac48e36f1fde5fa6b10f769442f Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 19 Nov 2014 03:14:29 +0100 Subject: utils: add after_this_request With after_this_request you can simple set cookies. Used as a decorator, it registers a function as callback to be executed just before sending the response to the client. The callback will be executed with the response object as argument. --- views.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'views.py') diff --git a/views.py b/views.py index 51b17ef..eed49df 100644 --- a/views.py +++ b/views.py @@ -13,6 +13,14 @@ def get_group_or_404(*query): Member.user == g.user, *query) return group + +@app.after_request +def call_after_request_callbacks(response): + for callback in getattr(g, 'after_request_callbacks', ()): + callback(response) + return response + + @app.route('/', methods=['GET', 'POST']) @templated('index.html') @auth.login_required -- cgit v1.2.3-1-g7c22