[Zope] calling zpt from a script with options

robert robert at redcor.ch
Thu Jan 6 16:54:01 EST 2005


Haim Ashkenazi wrote:

>Hi
>
>forgive me if it's trivial, but I'm a complete zope newbie....
>
>I read in the zope book that if I want to call zpt from a script (in my
>case, to render errors in a form) I do something like this:
>
>--
>script:
>
>pt = context.body_content
>s = pt(zerror="This is an error")
>return s
>
>zpt:
>
><i tal:content="options/zerror | default">error</i>
>--
>
>This works without a problem, but it only shows the "body_content" file.
>this file is part of a layout (inside a folder) and I want to call the
>folder as the url, so it will acquire the index_html in an upper directory.
>
>I tried changing the "pt" variable to context.index_html and calling
>"here/index_html/options/zerror" in the template but it didn't show. 
>  
>
options are the parameter with the actual template was called with.  
Therefore

here/index_html has not options since it is not called as a method.
If I understand your problem correctly, you shoud do something like:

script:

pt = context.index_html
return pt(zerror="This is an error")

zpt:
<div tal:define"error options/zerror | nothing" >  
  <i tal:content="error"  tal:condition="error" />
  <div tal:content="structure here/body_content" />
</div>

robert



More information about the Zope mailing list