[Grok-dev] Accessing a METAL template from another template

Sebastian Ware sebastian at urbantalk.se
Tue Jan 15 10:15:42 EST 2008


I managed to get it to work. The issue might have been that I put  
[metal:use-macro] before [metal:define-macro], but I am not sure  
because I have changed the source too many times.

Anyway, this mistake might be worth mentioning too. The wierd thing is  
that if you switch after you have rendered the page once with the  
statements in the correct order (define-macro before use-macro) and  
then render the page again without a restart, it works. But once you  
restart Zope, you get an error... switch the statements and it  
works... switch them again, and it still works... restart... error...

Mvh Sebastian

15 jan 2008 kl. 15.34 skrev Uli Fouquet:

> Hi Sebastian,
>
> Sebastian Ware wrote:
>> Unfortunately it only covers accessing a template from the current
>> view. This page explains what I am trying to do:
>>
>> http://www.zopelabs.com/cookbook/1053557445
>
> The master template in the macros tutorial Daniel pointed to, is a
> template for instances of ``Master`` view, which is not your 'current'
> view. Please review the 'all-purpose-macros' section.
>
> There is no limit in setting up 'masters' of 'masters'. Given you  
> have a
> main template 'master.pt', which is bound to a view 'Master' (as  
> done in
> the tutorial)::
>
> class Master(grok.View):
>     grok.context(Interface)
>
> then you can define::
>
> class Monkeybutter(grok.View):
>     grok.context(Interface) # Same as in the `Master` class
>
> or, for short::
>
> class Monkeybutter(Master):
>     pass
>
> Add a template ``monkeybutter.pt`` in `app_templates/` which  
> references
> the old master template as `context/@@master/macros/master` and
> reference the new fascade macros from, for example, indext.pt like
> this::
>
> context/@@monkeybutter/macros/master
>
> simply replacing '@@master' by '@@monkeybutter'.
>
> I assumed, this would be made clear in the tutorial. Maybe I should
> explain it more in-depth.
>
> BTW: In the macros-tutorial all macro references are shown as::
>
>          context/@@<viewname>/<macroname>
>
>    This is now deprecated and you should use instead::
>
>          context/@@<viewname>/macros/<macroname>
>
>    (with explicit 'macros/'). I will update this shortly.
>
> Hope that helps,
>
> -- 
> Uli
>
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev



More information about the Grok-dev mailing list