logo       

odd behavior with session variable that contains a list: msg#02317

DjangoUsers

Subject: odd behavior with session variable that contains a list


I am seeing some behavior with session that I don't understand. If I
have a session variable called recentAddIds that contains a list. I
find that if I append to that list, like this:

request.session['recentAddIds'].append(newlySavedId)

Then when I next receive a GET, I find that request.session
['recentAddIds'] does not contain the appended data (but does contain
the data that was there prior to the append).

If I instead make a copy of the list and put that copy into the
session variable, then when I next receive a GET, my session variable
does not contain the newly appended data.

request.session['recentAddIds'] = [x for x in request.session
['recentAddIds']] + [newlySavedId]

Can anyone explain why this is and if it is expected behavior? Is it
ok for sesion variables to contain lists or other complex structures,
or should they just be simple strings?

Margie
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
django-users+unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise