[Zope-dev] Strange session behaviour (persistent session data container + Page Reloads)
Hermann Himmelbauer
dusty at qwer.tk
Mon Jan 5 10:22:40 EST 2009
Hi,
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'] = []
sess['foo'].append('a')
sess['foo'].append('b')
sess['foo'].append('c')
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']
['a','b']
['a','c']
['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()
sess['foo'].append('a')
....
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,
Hermann
--
hermann at qwer.tk
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7
More information about the Zope-Dev
mailing list