[z3-five] (re)using zpt macros from view page templates
Philipp von Weitershausen
philipp at weitershausen.de
Tue Jan 30 14:35:31 CET 2007
Chris Withers wrote:
> Chris Withers wrote:
>
>> Any help greatfully received!
>
>> from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
>
> This was my mistake, that should have been:
>
> from Products.Five.browser.pagetemplatefile import \
> ZopeTwoPageTemplateFile
They're the same. It shouldn't make a difference.
> However, now using the right class...
>
> my_macro = ZopeTwoPageTemplateFile('my_macro.pt')
>
> my_macro.macros just gives me a ComputedAttribute object (rather than
> the macros I'd expect).
>
> If I do, my_macro.pt_macros(), I get the macros.
>
> Why isn't ComputedAttribute working in this example?
Coz ComputedAttribute is a stupid Zope2ism that only works in an
acquisition context.
I still think you're overcomplicating things. You don't really need any
python code. Just register your macro template as a browser:page and
then access the macro in the other template via
context/@@viewname_of_the_macrotemplate/macroname. I've spelt this out
already, it's your choice to do it or not. I won't give any predictions
on what else might work or not since this is the standard way of
accessing macros...
--
http://worldcookery.com -- Professional Zope documentation and training
Next Zope 3 training at Camp5: http://trizpug.org/boot-camp/camp5
More information about the z3-five
mailing list