[ZPT] Re: Re: a little more on scripts execution

Arnar Lundesgaard arnarlun@online.no
Sun, 4 Aug 2002 14:26:49 +0200


----- Original Message -----
From: "Michal Kurowski" <mkur@poczta.gazeta.pl>
Newsgroups: gmane.comp.web.zope.page-templates
Sent: Saturday, August 03, 2002 8:12 PM
Subject: Fwd: Re: a little more on scripts execution
>
> Quite true.
>
> But my problem is: how to use the "bind namespace" with ZPT.
>
> This is quite well documented (and works) with dtml, but not with ZPT.
>
> Thanks,
>

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



To get access to the different contexts, you simply use ns['here'] (or
similar) and
go from there.


  -- Arnar Lundesgaard