[ZPT] METAL Trickiness

Tim Moore tmoore@tembel.org
07 May 2001 23:47:35 +0000


OK, this is a little hard to explain, so forgive my verbosity.

Let's say I've got a ZClass called Foo, which is defined inside
another ZClass called FooFolder (which is of course an ObjectManager
that contains instances of Foo).

I would like to be able to view instances of Foo directly, so I've
created a page template called index_html that displays properties of
the instance in a table.

I would also like to have an index_html page template in the FooFolder
which basically gets each of the tables generated by its child Foos
and puts them into a bigger table.

In, DTML, I would probably do something like this:

FooFolder/Foo/index_html:

<dtml-var standard_html_header>
<dtml-var content>
<dtml-var standard_html_footer>

FooFolder/index_html:

<dtml-var standard_html_header>
<dtml-in "objectValues('Foo')">
<dtml-var content>
</dtml-in>
<dtml-var standard_html_footer>

(where "content" is some other DTML method defined in Foo that displays
that Foo)

I'm not sure how to do this in ZPT.  This is what I tried (basically)

FooFolder/Foo/index_html:
<html metal:use-macro="root/standard_tmpl/macros/master">
  <div metal:fill-slot="main">
    <table metal:define-macro="content">
     etc., etc.
    </table>
  </div>
</html>

FooFolder/index_html:
<html metal:use-macro="root/standard_tmpl/macros/master">
  <div metal:fill-slot="main">
    <table>
      <tr tal:repeat="foo python:objectValues('Foo')">
        <td>
          <table metal:use-macro="foo/macros/main">
          </table>
        </td>
      </tr>
    </table>
  </div>
</html>

I feel like this should work, but when I save
FooFolder/Foo/index_html, it changes 'metal:define-macro="content"' to
'metal:use-macro="root/standard_tmpl/macros/master"' and if I save it
a second time, it then of course inserts the master macro in place of
my content macro.

So, I take it that it is not possible to both use a macro and define a
different one in the same template.  Is this a bug?  Is there some
other way to do what I'm trying to accomplish?

thanks!
-- 
Tim Moore