librelist archives

« back to archive

Flash message and redirect

Flash message and redirect

From:
Thomas Beugin
Date:
2010-11-13 @ 10:43
Hello,

There is a way for seeing if flash method is use or counting flash
message before a redirect?


Thanks :)


Cordialement,
Beugin Thomas

Re: [flask] Flash message and redirect

From:
Dag Odenhall
Date:
2010-11-13 @ 22:32
On Sat, 2010-11-13 at 11:43 +0100, Thomas Beugin wrote:
> Hello,
> 
> There is a way for seeing if flash method is use or counting flash
> message before a redirect?
> 
> 
> Thanks :)
> 
> 
> Cordialement,
> Beugin Thomas

Untested:

@app.contextmanager
def hook_flashes():
    def wrapper(*args, **kwargs):
        do_hook_stuff()
        return get_flashed_messages(*args, **kwargs)
    return dict(get_flashed_messages=wrapper)