On Tue, Apr 8, 2008 at 6:39 PM, Christoph Haas <[EMAIL PROTECTED]> wrote:
>  Your class variables are not saved between HTTP requests. If you want
>  data to persist you either need to save it in into a database (hint:
>  model) or into the session (cookie based session).

Just to further explain what Christoph has said, since I had the same
misconception as Dave when I started writing web apps...

In the traditional software model, once an object is created within
the application, it remains there until either it is destroyed or the
application is closed. In Web Apps, this is not the case. In essence,
each and every page that you go to is a single execution of your
application... from startup to shutdown. This means that while the
page is loading your object is valid, but as soon as the page has
finished loading, your object has been destroyed. So any variables you
set in your controller are not available on the next page or function
execution.

As Christoph also said, the way to make data persist between different
pages is either via database storage, or via the "session" list object
in your controller. In Dave's case, he most probably wants to use the
session list object.

Here's an example:

if 'message' not in session:
    session['message'] = 'This is a message'
    session.save()


-- 
Raoul Snyman
B.Tech Information Technology (Software Engineering)
E-Mail: [EMAIL PROTECTED]
Web: http://www.saturnlaboratories.co.za/
Blog: http://blog.saturnlaboratories.co.za/
Mobile: 082 550 3754
Registered Linux User #333298 (http://counter.li.org)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to