Background: how grok.View and macros interact¶
The template attribute and the macro shortcut convention¶
In the case of grok.View views, they subclass the Zope 3 BrowserPage
objects which provide an attribute template, which is the associated page
template. The associated page template in turn has got an attribute macros,
which is a dictionary containing all the macros defined in the page template
with their names as keys (or None).
This means, that you can also reference a macro of a grok.View using:
context/<view-name>/template/macros/<macro-name>
Grok shortens this path for you by mapping the macros dictionary keys to
the associated grok.View. If you define a macro mymacro in a template
associated with a grok.View called myview, this view will map
mymacro as an attribute, so that you can ask for the attribute mymacro
of the view, where as it is in fact an attribute of the associated template.
Such, you can write in short for the above pattern:
context/<view-name>/macros/<macro-name>
View names always start with the ‘eyes’ (@@) which is a shortcut
for ++view++<view-name>.
