[Zope] TOC ondelete event

Jonathan dev101 at magma.ca
Sat Jul 28 08:17:08 EDT 2007


----- Original Message ----- 
From: <jbusato at libero.it>
To: "zope" <zope at zope.org>
Sent: Saturday, July 28, 2007 7:15 AM
Subject: [Zope] TOC ondelete event

> I'm setting up a Session data Manager with a Transient Object Container 
> that call a python script session_delete?
>(sdo,toc).
>
> I want to show a message like ("your session was terminated due 
> inactivity") so I tried to write this
>
> #PYTHON SCRIPT (NOT EXTERNAL) session_delete(sdo,toc)
> request = container.REQUEST
> RESPONSE =  request.RESPONSE
> RESPONSE.redirect(container.mywarningpage.absolute_url())
>
> Launched manually it gives me no errors but when the session is terminated 
> only "onadd" script make effects.
>
> Are there not permitted operations in this case?
> Could anyone explain me where I mistake or another way to do tha same 
> thing? (AFAIK sdo parameter is the old
> session so I can't store any info in it)

The TOC invokes your script when the "data object timeout value" is reached 
(eg. if the timeout value is set for 5 minutes, then the TOC will invoke the 
"script to call when objects are deleted" when there has been no activity 
for 5 minutes).

The TOC invokes the delete script as a result of the timeout, not because of 
an incoming user request and therefore there is no user to be 'redirected'. 
You are trying to push out a message to a user that is no longer "there".

You need to revise your application logic so that if a user comes back 
(makes another request) after the 'timeout' they receive your warning 
message.

hth

Jonathan




More information about the Zope mailing list