[Zope3-Users] Beginner: Reference to ZPT macros

Hermann Himmelbauer dusty at qwer.tk
Thu Jan 17 01:53:06 EST 2008


Am Mittwoch, 16. Januar 2008 19:27 schrieb Achim Domma:
> Hi,
>
> I have a simple view. Here is the entry in configure.zcml:
>
>    <browser:page
>        for=".CMS.Page"
>        name="index.html"
>        class=".CMS.PageView"
>        permission="zope.Public"
>        template="index.pt"
>        menu="zmi_views"
>        title="Default View"
>        />
>
> The view works fine so far, but now I want to use a template macro to
> implement a common layout. So I created a layout.pt in the same
> folder as index.pt. In index.pt I try to reference layout.pt like this:
>
> <div xmlns:metal="http://xml.zope.org/namespaces/metal" metal:use-
> macro="context/@@layout.pt/macros/default_layout">
>      <div metal:fill-slot="content">
>          <div tal:content="structure view/html_content"></div>
>      </div>
> </div>
>
> Now I get an TraversalError but I could not figure out why. How do I
> have to reference layout.pt? Do I have to register the emplate
> somehow? I work with Philips book, but he uses a template created via
> ZMI in his example.

Hav a look at skin/standardmacros.py in the worldcookery examples: There you 
can see the mechanism that allows other pages to access the macros.

I personally don't like macros that much, therefore I prefer Stephan Richters 
pagelet/viewlet approach, which you can find in z3c.pagelet.

Best Regards,
Hermann

-- 
hermann at qwer.tk
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7


More information about the Zope3-users mailing list