[EMAIL PROTECTED] wrote:
> How save data between controllers w/o using database?
>
> (I may not need data long term so don't want to touch the database
> until then.)
>
> I added instance variables to Root class in controllers.py
> by setting stuff like self.var1 in an __init__(self) method.
>
> By altering values of self.var1 I can save data between controller
> methods.
>
> Is this best way to do it?

That's one place to put it. You can also stick the data into any
persistent object or module (basically anything except, say, the
Request object, which gets created fresh for each request). I tend to
use module-level globals for such things. Regardless of where you put
it, you just need to be careful you don't run into problems with
multiple threads overlapping operations on it. See
http://effbot.org/pyfaq/what-kinds-of-global-value-mutation-are-thread-safe.htm
for a short intro to this kind of safety.

> (BTW..is temporary storage like this what is referred to as a 'session'
> ?)

Not really; the session isn't global scope. Instead, it's per-user and
even per "browser session"; that is, if the user closes the browser and
starts over, they'll get a new session.


Robert Brewer
System Architect
Amor Ministries
[EMAIL PROTECTED]


--~--~---------~--~----~------------~-------~--~----~
 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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to