I experience a strange behavior of persistent session data container here. I 
configured the container as described in various sources, and, what I do 
next, is something like that:

sess = ISession(self.request)['mykey']
print id(sess)

This outputs an arbitrary ID of the session object. Interestingly, that the ID 
is always the same, if I enter the URL in my browser and press "enter". When 
I, however, hit my reload button, the ID changes.

So far, so good. What I do next in my view is to add data like this:

sess['foo'] = []

Now I have some code like this:

print sess['foo']

I'd expect an output of ['a','b','c'], which Zope does, in case I enter the 
URL and press Enter. However, if I press "Reload" multiple times, the output 
looks something like that:


['a','b','c'] is never displayed, and the above values are shown in an 
arbitrary manner. But interestingly, 'a' is always there, the list is never 
empty. Moreover, it's interesting, that the object id of the list changes 
when pressing Reload.

I now changed my code to a PersistentList:

sess['foo'] = PersistentList()

And this seems to work, also for reloads.

Can someone please enlighten me, why this happens? Is it mandatory to use 
PersistenList instead of a common list when using persistent session data 
containers? What about PersistentDict/Dict? Why is a Reload so different to a 
normal page load?

Best Regards,

GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to