2009/5/30 Branko Vukelic <[email protected]>: > > If you have code like: > > class something: > def GET(self): > # show something > def POST(self): > i = web.input() > if i.somefield: > db.insert(params for insert) > message = "SUCESS! Hooray!" > else: > message = "ERROR!!!" > raise web.seeother(someurl) > > How do you get the `message` to display in whatever template is used for GET?
Thats very tricky. It is called flash message and most web frameworks have support for that. Typically it is implemented by making the template display all the available flash messages and delete them. To display a flash message, message is added to session before the redirect. After redirect the new page will display them and delete. watchdog.net uses a cookie based implementation of displaying flash messages. http://github.com/aaronsw/watchdog/blob/b012e33f9d3186138488fba5a507bc58e9fb81b5/utils/helpers.py#L40 Anand --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/webpy?hl=en -~----------~----~----~----~------~----~------~--~---
