Thanks to both Paul and AJ -- both suggestions were helpful. The extended description Paul gave me below was particularly use.
Here's what I learned:
1) the form object is automagically handed to the template when you do a 'return context.mytemplate(item='something')
2) I assumed that I would have to pass the form object to the template -- but this is not needed. More usefull is that when 'item' is given to the template as parameter, shown above, that the template gets a NEW? namespace called 'options'. I think this is new to me.
3) then, within the template the tales expression options/item gives me 'something'.
This really helps me understand better how script and templates work together. A year from now, I'll need to relearn this again and may google my answer above...
Thanks to all on the plone list.
On Wed, Sep 10, 2008 at 07:57:29PM -0700, David Bear wrote:
> I have a script that calls a template.
>
> The template has a tal expressions like this
>
> <p tal:content="structure here/ploneDoc/getText"> </p>
>
> I want my script to call the template in such a way that the string
> 'ploneDoc' is replaced by a different string.
>
> I'm not sure how to go about parameterizing a tales expressions like
> this.
It is possible, by sticking a question mark in front of ploneDoc; but
afaict you can only use a variable already in the namespace,
i.e. you'd have to define it first. Like so:
<p tal:define="docname options/ploneDoc"
tal:content="structure here/?docname/getText"> </p>
But I have literally never seen this obscure feature in real use,
because nobody seems to know about it (I had forgotten it myself), and
because it's not necessary. I'd prefer to have the script just pass in
the object you want, as per this document:
http://plope.com/Books/2_7Edition/BasicScripting.stx#1-3
So, in your script, something like:
doc = context.restrictedTraverse(some_path)
return context.mytemplate(mydoc=doc)
Then, in your template just do:
<p tal:content="structure options/mydoc/getText"></p>
--
Paul Winkler
http://www.slinkp.com
_______________________________________________
Zope maillist - Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )