[Grok-dev] How do I reference a common template in the statics
sebastian at urbantalk.se
Thu Jul 5 04:10:15 EDT 2007
Thanks! But I am still missing something:
TraversalError: (<protoncms.protonworkflow.ProtonWorkflow object at
I have created macros.py...
from zope.interface import Interface
...and I have defined...
[...] metal:define-macro="admin" [...]
...and I call it with...
[...] metal:use-macro="context/@@macros/admin" [...]
I am probably missing something simple, but I am at a loss... :)
5 jul 2007 kl. 01.28 skrev Uli Fouquet:
> Hi Sebastian,
> On Thu, 05.07.2007, 00:32 +0200 Sebastian Ware wrote:
>> I am creating a "define-macro" page template, which I have put in my
>> static directory. But how do I reference it in "use-macro" and do I
>> need to create a class for this page template?
> I think you indeed should define an appropriate class (and remove your
> pt from 'static', macros are not static ;-) or things become quite
> difficult. The method I personally like best:
> - Define a class `Master(grok.View)` in a module `macros.py`. You can
> make sure, that the context of the class binds to all other views,
> like this::
> from zope.interface import Interface
> import grok
> class Master(grok.View):
> You don't *need* to register a macro-template for all views, but
> you can also write one just for views of a certain model. Use this
> model as context then. Also you don't *have* to define the macros
> class in its own module (although it makes your code more
> from my point of view). But, yes, you need to give an associated
> - Then, in the subdirectory `macros_templates`, create a page
> template `master.pt` with your standard macros.
>> From any other of your page templates you then can call the macros in
> `master.pt` like this::
> <html metal:use-macro="context/@@master/mypagemacro">
> or similar.
> I think, I have seen that method (the thing with 'Interface') first in
> one of Philipps applications (nudgenudge?) and like it.
> Hope that helps,
> Grok-dev mailing list
> Grok-dev at zope.org
More information about the Grok-dev