[ZPT] Re: a little more on scripts execution

Michal Kurowski mkur@poczta.gazeta.pl
Sun, 4 Aug 2002 18:58:47 +0200


Arnar Lundesgaard [arnarlun@online.no] wrote:
>
> Not sure this is exactly what you want, but you could try this:
> 
> <!-- start 'testTemplate.pt' -->
> <html>
>   <head>
>     <title>Namespace example</title>
>   </head>
>   <body>
>     <span tal:define="text string:Unchanged">
>       <span tal:replace="text"/><br>
>       <span tal:replace="here/testScript.py" />
>     </span>
>   </body>
> </html>
> <!-- stop 'testTemplate.pt' -->
> 
> ## Script (Python) "testScript.py"
> ##bind container=container
> ##bind context=context
> ##bind namespace=ns
> ##bind script=script
> ##bind subpath=traverse_subpath
> ##parameters=
> ##title=
> ##
> text = ns['text']
> text = 'Changed'
> return text
> 
> 
> 
> In ZOPE 2.5.1 this gives me:
>   Unchanged
>   Changed

Wait, wait.
>From what I can see you just redefined a variable and no matter
what happened before "testScript" (".py" not allowed) always returns
"Changed". In the end in a template you've got a variable that renders to 
"Unchanged" string and a script which is going to return "Changed"
regardless of any namespace issues.

In fact the question is: will the script see the "ns['text']"  construct
or not ?

My current experience is - it will not.

If anybody knows more - please comment.

Thanks,

-- 
Michal Kurowski
<mkur@poczta.gazeta.pl>