[Zope] Request & has_key

Philip Kilner phil at xfr.co.uk
Fri Apr 23 03:08:46 EDT 2004


Hi Ausum,

Ausum Studio wrote:
> Your problem is that the variable set via "container.REQUEST.set" won't
> persist. (Not that I know). If you want to use or process a variable within
> one request, you use the object context.REQUEST, but its variables will die
> at the moment you spawn a new one. If you need persistent client-side
> variables you can use cookies:
> 
> RESPONSE.setCookie(varname=varvalue)
> 
> .. sessions:
> 
> REQUEST.SESSION[varname] = varvalue
> 
> .. or grab variables from a previous request, embedding hidden form objects
> in a form, before submitting it with the new one. There's plenty of
> documentation on the first two alternatives.
> 

D'Oh!

I read the above with a creeping sense of stupidity - I've been doing 
this stuff for a long time now in other environments where there is no 
direct equivalent of "container.REQUEST.set", and know fine well that 
"request" isn't persistent - but I'd never thought through properly what 
"container.REQUEST.set" was actually doing, and had managed to confuse 
myself in this case by running two scripts from the same ZPT. Now I've 
untangled the unnecessary complexity of this, I realise that where I'd 
thought that I'd understood the scope of this construct, I'd actually 
been kidding myself and the data I was looking at came from the other 
script!

I'm pretty sure I need to use REQUEST.SESSION - although that adds 
another element of complexity in that I have to factor in the 
possibility that a use may open a second instance of his browser. Am I 
right in thinking that these two instances would effectively share a 
session, and that I therefore need to identify my transactions manually?

Thanks for bearing with me long enough to identify my error!

Cheers,

PhilK




More information about the Zope mailing list