[ZPT] Re: a little more on scripts execution

Michal Kurowski michal@genesilico.pl
Sat, 10 Aug 2002 21:45:25 +0200


Arnar Lundesgaard [arnar.lundesgaard@creuna.no] wrote:
> 
> <html>
> <head><title>Dictionary example</title></head>
> <body>
>   <span tal:define="text python:{'one':1,'two':2}">
>     One: <span tal:replace="text/one" /><br>
>     Two: <span tal:replace="text/two" /><br>
>   <span tal:define="dummy here/testScript.py" /><br>
>     One: <span tal:replace="text/one" /><br>
>     Two: <span tal:replace="text/two" /><br>
>   </span>
>   <hr>
> </body>
> </html>
> 
> ## 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']
> 
> if same_type(text, {}):
>   text['one']='***'
> 
> return text
> 
> 
> Which in ZOPE 2.5.1 gives me:
>   One: 1
>   Two: 2
> 
>   One: ***
>   Two: 2
> 

That work ok for me but it cannot be used for example for creating
links like that:


  <span tal:define="dummy here/testScript" /><br>
    One: <a href tal:attributes="href
    here/testScript/absolute_url">jeden link</a><br>
    Two: <a href tal:attributes="href
    here/testScript/absolute_url">drugi link</a> <br>
  </span>


Unfortanelly that only confirms my guess that namespace cannot be (easlly) 
used to pass varaiables.

Cheers,

-- 
Michal Kurowski
<michal@genesilico.pl>