session invalidate - using python
Using this simple script, I expected that a None should be returned (according to http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/Sessions.stx): data = context.session_data_manager.getSessionData( create=0 ) data.invalidate() return str( data ) # str() just to see None But a result like this is allways returned: id: 10360120480192202025, token: 54001646A0iEAi2X9io, contents: [] with id change at each call (token is the same because the browser is the same). A new session is ceated at each hit (refresh) in the same browser: and the counter in the transient object container is increased accordingly. I did put Data object timeout value in minutes = 1, but after 30 minuts a new hit increase the counter. Does create=0 work properly? Does invalidate() work at all? What am I doing wrong? Thanks for help. p.t.
No. By doing data.invalidate(), you've invalidated the data object (which means it will eventually be removed from the session data container), but that won't magically turn it in to the None object. It makes sense that on each call you're getting a new data object as you're invalidating the old one. getSessionData returns a session data object associated with the current browser id. The "create=0" argument doesn't mean "dont create a session data object", it means "don't create a session data object unless there is a current browser id". Since there is a current browser id, a session data object is returned instead of None. ----- Original Message ----- From: "p.t." <p.training@tin.it> To: "'Zope@Zope. Org' (E-mail)" <zope@zope.org> Sent: Wednesday, October 30, 2002 4:22 PM Subject: [Zope] session invalidate - using python
Using this simple script, I expected that a None should be returned (according to
http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/Sessions .stx):
data = context.session_data_manager.getSessionData( create=0 ) data.invalidate() return str( data ) # str() just to see None
But a result like this is allways returned:
id: 10360120480192202025, token: 54001646A0iEAi2X9io, contents: []
with id change at each call (token is the same because the browser
is the
same). A new session is ceated at each hit (refresh) in the same browser: and the counter in the transient object container is increased accordingly. I did put Data object timeout value in minutes = 1, but after 30 minuts a new hit increase the counter.
Does create=0 work properly? Does invalidate() work at all? What am I doing wrong?
Thanks for help. p.t.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Chris, thanks for the very clear explanation. In effect, I was trying to undestand how session expiring works, because I'm looking for a way to detect when a request coming from a browser associated to a session find the session expired. Have you a suggestion? TIA, p.t. At 16:53 30/10/2002 -0500, Chris McDonough wrote:
No. By doing data.invalidate(), you've invalidated the data object (which means it will eventually be removed from the session data container), but that won't magically turn it in to the None object.
It makes sense that on each call you're getting a new data object as you're invalidating the old one.
getSessionData returns a session data object associated with the current browser id. The "create=0" argument doesn't mean "dont create a session data object", it means "don't create a session data object unless there is a current browser id". Since there is a current browser id, a session data object is returned instead of None.
I would just add a key/value pair to the session data object at some opportune point in the user's experience with your site. If it doesn't exist, the session data object is new or an old one has been expired. - C ----- Original Message ----- From: "p.t." <p.training@tin.it> To: "Chris McDonough" <chrism@zope.com>; "'Zope@Zope. Org' (E-mail)" <zope@zope.org> Sent: Wednesday, October 30, 2002 5:26 PM Subject: Re: [Zope] session invalidate - using python
Chris, thanks for the very clear explanation. In effect, I was trying to undestand how session expiring works, because I'm looking for a way to detect when a request coming from a browser associated to a session find the session expired. Have you a suggestion? TIA, p.t.
At 16:53 30/10/2002 -0500, Chris McDonough wrote:
No. By doing data.invalidate(), you've invalidated the data object (which means it will eventually be removed from the session data container), but that won't magically turn it in to the None object.
It makes sense that on each call you're getting a new data object as you're invalidating the old one.
getSessionData returns a session data object associated with the current browser id. The "create=0" argument doesn't mean "dont create a session data object", it means "don't create a session data object unless there is a current browser id". Since there is a current browser id, a session data object is returned instead of None.
participants (2)
-
Chris McDonough -
p.t.