<s> """<STR_LIT>""" <EOL> import json <EOL> import web <EOL> def get_flashed_messages ( ) : <EOL> if "<STR_LIT>" not in web . ctx : <EOL> web . ctx . flashed_messages = web . ctx . get ( '<STR_LIT>' , [ ] ) <EOL> web . ctx . flashes = [ ] <EOL> return web . ctx . flashed_messages <EOL> def flash ( message , category = "<STR_LIT:info>" ) : <EOL> flashes = web . ctx . setdefault ( '<STR_LIT>' , [ ] ) <EOL> flashes . append ( web . storage ( category = category , message = message ) ) <EOL> def flash_processor ( handler ) : <EOL> flashes_json = web . cookies ( flashes = "<STR_LIT>" ) . flashes <EOL> try : <EOL> flashes = [ web . storage ( d ) for d in json . loads ( flashes_json ) <EOL> if isinstance ( d , dict ) and '<STR_LIT>' in d and <EOL> '<STR_LIT:message>' in d ] <EOL> except ValueError : <EOL> flashes = [ ] <EOL> web . ctx . flashes = list ( flashes ) <EOL> try : <EOL> return handler ( ) <EOL> finally : <EOL> if flashes != web . ctx . flashes : <EOL> if web . ctx . flashes : <EOL> web . setcookie ( '<STR_LIT>' , json . dumps ( web . ctx . flashes ) ) <EOL> else : <EOL> web . setcookie ( '<STR_LIT>' , '<STR_LIT>' , expires = - <NUM_LIT:1> ) </s>
