I ran into this too.

I don't know if the behaviour is a bug, or just if we are
misinterpreting the intended purpose of flash.

How flash works is to set a cookie which is sent to the browser.  The
message only gets displayed when the cookie comes back from the
browser.  The cookie is then deleted once it has been read back by the
server.  That's why it only shows up every other time.  It has to get to
the browser and come back to be displayed.  And once it is aback is it
removed.  If a new one is set at that time, then it has to do the full
trip again to be displayed.

I ended up just passing in my own message variable to the template and
having the template show the message if it exists. (Basically
duplicating the flash functionality but without using cookies.)

If this is not a bug, then I'd love to see documentation explaining the
purpose and semantics of using flash, particularly in conjunction with
HTTPRedirect and InternalRedirect.

Hope this helps,
Krys

Tim Lesher wrote:

>[Env: Turbogears 0.5, running on Windows XP]
>
>I have a template containing a form, which posts back to the same URL.
> My controller looks like this:
>
>@turbogears.expose(html="yadda")
>def showStuff(self, **kwargs):
>    if 'submit' in kwargs:
>        # [ Update the db ]
>        turbogears.flash('DB Updated')
>    return dict(...yadda...)
>
>This works fine--the db gets updated every time, but the flash message
>is only displayed on every _other_ try.  In other words, if I just
>bounce on the Submit button, I see the flash message on one view, then
>nothing the next view, then I see the flash message on the third view,
>etc.
>
>Am I misusing flash here?
>
>If not, I'll cobble up a minimal example to show the problem.
>
>Thanks!
>--
>Tim Lesher <[EMAIL PROTECTED]>
>
>  
>

Reply via email to