Faced with a similar problem, I used approach 2, with a function global at the template level (my base template) that pops any messages, if any, from the session storage object and displays them, a somewhat similar approach to what `django` does.
I did this to avoid having to deal with this in every URL handler. On Wednesday, August 7, 2013 5:14:04 AM UTC+3, Bill Seitz wrote: > > Cool, thanks. I'm going with session.msg... > > On Tuesday, August 6, 2013 3:46:01 PM UTC-5, NSC wrote: >> >> I guess the answer is yes. I should have clarified that I have a >> common.py module that's imported on all of my pages. The message goes in >> the common class. >> >> >> On Tue, Aug 6, 2013 at 4:34 PM, Bill Seitz <[email protected]> wrote: >> >>> So then does every page class need to start with a 'msg = None' bit to >>> reset things? >>> >>> >>> On Tuesday, August 6, 2013 1:32:25 PM UTC-5, NSC wrote: >>> >>>> I'm often frustrated by the encoding and display intricacies of passing >>>> messages around in gets/posts, so I usually end up doing one of the >>>> following. (Choose the one that's best for your situation.) >>>> >>>> 1) put the message in a cookie, then have the target page (or all pages >>>> for that matter) check the 'message' cookie and display whatever is in >>>> there. >>>> >>>> 2) stick a message in a session variable (if you're using session) and >>>> display whatever message is there. >>>> >>>> These two have always worked for me. I usually do # 2, and have code >>>> on every page to check for messages and display. I also have a shared >>>> javascript lib for how the message is presented, so it works on every page. >>>> >>>> Hope this helps... S >>>> >>>> >>>> >>>> On Tue, Aug 6, 2013 at 2:12 PM, Bill Seitz <[email protected]> wrote: >>>> >>>>> Often, after a user POST, I want to end by redirecting to a URL. >>>>> Sometimes I want to pass along a status message and have that displayed >>>>> on >>>>> the target URL page. >>>>> >>>>> My first thought is to >>>>> 1. pass the message as url-query-arg - web.found(target + '?msg=$msg) >>>>> 2. have a handler in the base layout - $if msg.... >>>>> >>>>> But: >>>>> a. is this a bad security risk? >>>>> b. if not, what am I missing as the process for catching the msg in >>>>> the base layout? Backtrace shows that the msg is there within >>>>> request/input >>>>> but seem to need some with/import/whatever to get access to it.... >>>>> >>>>> thx >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "web.py" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> To post to this group, send email to [email protected]. >>>>> >>>>> Visit this group at http://groups.google.com/group/webpy. >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>>> >>>>> >>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "web.py" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at http://groups.google.com/group/webpy. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> -- You received this message because you are subscribed to the Google Groups "web.py" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/webpy. For more options, visit https://groups.google.com/d/optout.
