[Zope] different namespaces in a python script by callingit by<dtml-var xxx> and <dtml-var "xxx()">?

Chris Withers chrisw@nipltd.com
Thu, 19 Jul 2001 21:19:32 +0100


Grégoire Weber wrote:
> 
> > This is the equivalent of:
> > <dtml-var "xxx(_.None,_)">
> 
> I have additional parameters so I replaced the '_.None'
> by the parameters like this (as I suppose, the _.None
> is only used if there are no parameters at all):
> 
>    <dtml-var "xxx(anypar='foo_par',_=_)">

Okay, given that I said you need to have _.None and _ as the first two
parameters, why are you suprised that things don't work when you suddenly stop
doing this? ;-)

try:

<dtml-var "xxx(_.None,_,anypar='foo_par')">

> Questions which turn up (just for interest):
> 
> 1) Why isn't this done automagically by setting the 'Namespace'
>    thing in the bindings tab to '_'? So that the caller does not
>    have to grant access to '_' to the calles Python Script
>    explicitly?

Why should the function being called have influence over the parameters passed
to it?
By going into python (anything inside double quotes in DTML), you bypass the
(bad) magic which usually does this.

> 2) Isn't there really any possibility for the Script to access
>    the '_' namespace of it's own? It seems that I have access
>    to the '_' namespace version which is set up at the
>    beginning of the request.

What are you looking to achieve here?

> 3) Why do DTML know about the actual namespace of the calling
>    methods and Python Scripts not?

They both know about exactly the same things. If you call a DTML method with:

<dtml-var "my_dtml_method()">

...you will experience exactly the same problems.

> It seems to me that Python Scripts do not at all have the same
> behaviour as DTML methods have. :-(

Nah, they all behave the same way in this situation: badly. Viva la New
Religion.

> P.S.: Is there a documentation about thsi anywhere?

...the source :-S
...the mailing list archives...

Old Skool Zope Style,

Chris