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

Fernando Martins fernando at cmartins.demon.nl
Thu Apr 15 17:03:38 EDT 2004


Casey Duncan wrote:
> "Fernando Martins" <fernando at cmartins.demon.nl> wrote:
> > 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

I'm really not familiar with DTML (and happy about that from what I've
seen). Does the problem come from the "implicitness"? Why not have an
explicit binding for the calling template, or treating the Script as a
method of the object "template"?

In fact, I was surprised to see that "context" seems to be the folder of the
template and not the template itself.

> 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>
>

Well, that's what I'm doing but the clarification was usefull anyways,
thanks.

Fernando




More information about the ZPT mailing list