[Zope] Python Script REQUEST namespace not found.

H.Tan htan@gmx.de
Thu, 5 Sep 2002 10:48:32 +0800


this is interesting to know that there is a magic around ZPublisher.
But I believe, there must be a definite answer to get Python Script reading
variable in REQUEST namespace.

I tried using Session object and it works.

Below is my code:

---------------------------
DTML-document: helloDoc

<dtml-call "SESSION.set('name', 'john') ">
<dtml-var hello>

---------------------------------
Python Script 'hello'
Parameter name='world'

session=context.REQUEST.SESSION
l=session['name']

return "Hello %s" %l

----------------------------------

The result is: 'hello john' which is correct result.



----- Original Message -----
From: "Dieter Maurer" <dieter@handshake.de>
To: "H.Tan" <htan@gmx.de>
Cc: <zope@zope.org>
Sent: Thursday, September 05, 2002 2:30 AM
Subject: Re: [Zope] Python Script REQUEST namespace not found.


> H.Tan writes:
>  > I'm trying to write my first python script by passing parameter through
the
>  > REQUEST object as following:
>  >
>  >
>  > ---------------------------
>  > In the Python Script:
>  >
>  > Parameter: name="world"
>  > return "Hello %s" %name
>  > ------------------------
>  >
>  > in my DTML-Document:
>  >
>  > <dtml-call "REQUEST.set('name', 'John')">
>  > <dtml-var hello>
> Parameters are only magically passed into Python scripts when they
> are called directly from the Web (this is ZPublisher magic)
> or when they bind (--> "Bindings" tab) the DTML namespace (this is
> DTML magic).
>
> When possible, you should not rely on magic, but pass the parameters
> explicitly:
>
> <dtml-var expr="hello('John')">
>
>
> Dieter
>