[ZPT] Re: Accessing ZPT options name in Python Script

Casey Duncan casey at zope.com
Thu Apr 15 15:02:55 EDT 2004


On Thu, 15 Apr 2004 00:39:31 +0200
"Fernando Martins" <fernando at cmartins.demon.nl> wrote:

> Hi,
> 
> Is there a way in a Python Script called from a Page Template to
> access the options name(space) of the page template itself?
> 
> Of course this could be passed to the script by using its parameters
> but I was thinking more on a binding-based solution (which I couldn't
> figure out).

There is no implicit binding between namespaces here like there was in
DTML, and that's a good thing! 'options' is just a dictionary (or
dict-alike thing) so it should be easy to map it to kwargs in the python
script or you can just pass it as a single argument. Imagine a script::

  ## Script (Python) "get_stuff"
  ##parameters=stuff
  return 'you passed me %s' % stuff.keys()

And in a template somewhere::

  <div tal:content="python:here.get_stuff(options)">
    Stuff goes here</div>

hth,

-Casey





More information about the ZPT mailing list