[Zope] Request & has_key

Ausum Studio ausum_studio at hotmail.com
Wed Apr 21 19:36:46 EDT 2004


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.


Ausum


----- Original Message ----- 
From: "Philip Kilner" <phil at xfr.co.uk>
To: "Ausum Studio" <ausum_studio at hotmail.com>
Cc: <zope at zope.org>
Sent: Wednesday, April 21, 2004 6:14 PM
Subject: Re: [Zope] Request & has_key


> Hi Ausum,
>
> Ausum Studio wrote:
> >>- How can I reliably check for the existence of a given key in the
> > request?
> >
> > You use REQUEST.has_key as you already know.
> ...[snipped references to solved problem re. string vs. integer]...
> > So your previous sentences
> > should need to look like this:
> >
> > if req.has_key('job_step'):
> >
>
> The problem is that this test /always/ fails - if I leave this logic in
> place, I simply repeat the initialisation /ad infinitum/. If I bodge
> this check (do-able in a test environment), the logic unfolds as intended.
>
> I'm sure I'm missing something simple - but I am at a loss as to what!
>
> > Zope properties machinery doesn't need this as far as you provide a
compound
> > value like 1:int for the variable name 'job_step'. But that doesn't work
in
> > custom created form validation.
> >
>
> I don't follow this - could you expand a little, or direct me to a
> fuller explanation, please?
>
> Cheers,
>
> PhilK
>
>



More information about the Zope mailing list