[Zope] Re: REQUEST.set question

Dylan Reinhardt zope at dylanreinhardt.com
Wed Dec 3 14:53:31 EST 2003


On Wed, 2003-12-03 at 09:11, Mark Ferguson wrote:
> The whole point of my question was about getting parameters from the REQUEST
> object into Python scripts, so perhaps if I restate the example -
> 
> I've got a DTML Document called hDoc:
>   <form action="./hDoc" method="POST">
>     Name: <input type="text" name="name" value="">
>     <input type="submit" value="Submit">
>   </form>
>   <dtml-if "REQUEST.get('REQUEST_METHOD') == 'POST'">
>     <dtml-var hello>
>   </dtml-if>
> 
> and a Python script -
>    return "Hello %s!" % name

If you expect your Python Script to obtain "name" from the REQUEST, it
needs to do this:

return "Hello %s" % REQUEST.get('name', 'anonymous')

Otherwise, pass name as an argument when you call the script:

<dtml-var "hello(name)">

Either one should work fine.

HTH,

Dylan





More information about the Zope mailing list