[Zope] Request & has_key

Philip Kilner phil at xfr.co.uk
Wed Apr 21 15:27:31 EDT 2004


Hi Tom,

Passin, Tom wrote:
>>req = context.REQUEST
>>
>>if req.has_key('job_step'):
>>
>>     if req.job_step == 1:
>>         do that...
>>
...[snip]...
> 
> _Which_ test fails?
> 
> 1) if req.has-key(), or
> 

Yup, the test for the existence of the key is the one I'm stuck on...

> 2) if req.job_step == 1
> 
> If the latter, you are getting the form data as a string, and you have
> to convert it into an integer to get what you want.
> 

...although when I have bodged my script to bypass this test, I have 
indeed hit the problem you suggest. Fortunately, my dog-eared copy of 
"Learning Python" (You'd think anyone who could so batter a book would 
have picked up more...) got me out of that one!

Ta!

Any clue about the if req.has_key('job_step') line?

Cheers,

PhilK




More information about the Zope mailing list