On Aug 28, 2006, at 10:14 AM, Adam Jones wrote:

I wonder if storing that in a cookie is really such a good idea? Well,

at least without telling people that it is stored in a cookie. Although

now that I think about it, how else would you do such a thing in TG?

The only other option I can think of would require identity, and I am

not even sure what I am thinking is correct. Mostly though I am worried

that people will rely on tg_flash for notifications and forget to tell

people that they need cookies turned on for that to work.


I'ts both stored in a cookie and sent in "tg_flash" to the template so both of the following snippets can work:

1)

def controller_method(....):
# save data
flash("Your data was saved")
redirect(...)

2)

def controller_method(....):
if a:
flash("a is true")
return dict(...)

As you can see, 1) is issuing a HTTP redirect so the only way to store state between this request and the one answering the redirect is with a cookie.

In 2) the message is just stored in tg_flash and shown in the same request.

As it has been mentioned, you can store almost anything in tg_flash if you encode it in JSON and process it client-side with _javascript_.. You can look at an example of using this technique here:


HTH,
Alberto.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" 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/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to