[Zope] Problem when trying to use metal macros from another page
template
Dieter Maurer
dieter at handshake.de
Wed Nov 5 17:09:19 EST 2003
Josef Meile wrote at 2003-11-5 14:18 +0100:
> ...
> I have the following structure:
>
> Base Class JMZPTMacros:
>
> <ZopeHome>/lib/python/Shared/JMUtils/JMZPTMacros.py
> <ZopeHome>/lib/python/Shared/JMUtils/zpt:
> Here I have the following Page Templates with some macros
> that I use from my other product JMBoring:
> generic.zpt
> generic_add.zpt
> ...
> Product JMBoring, which subclases from JMZPTMacros:
>
> ...
> JMBoring_Add.zpt
> ...
>
> What I'm trying to do is to call some macros from "generic.zpt"
> and "generic_add.zpt" in "JMBoring_Add.zpt". The main problem
> is that the "JMBoring_Add.zpt" Template is loaded outside of
> the JMBoring class definition (constructor methods are declared
> before the classe definition), while the other Templates like:
> "manage_view", "index_html", and "manage_main" are inside, so,
> they can access the macros in the "JMZPTMacros" base class
> just by typing:
>
> <p metal:use-macro="here/TemplateID/macros/MacroID">Execute macro</p>
>
> but in the JMBoring_Add.zpt, an AttributeError exception is
> raised.
Make them additional constructors in your "registerClass".
This ensures that they are registered in your "Product factory"
and can be accessed in the usual way.
--
Dieter
More information about the Zope
mailing list