[Grok-dev] Viewlets template inheritance broken if in another package?

Jan-Wijbrand Kolman janwijbrand at gmail.com
Mon Oct 19 10:03:27 EDT 2009

Mikko Ohtamaa_ wrote:
> Hi,
> I am using five.grok to cook up some viewlets.
> I'd like to make viewlets reusable, so that other *packages* should subclass
> them.
> foo.package1
> foo.package1/templates/head.pt
> class HeadViewlet(grok.Viewlet):
>    grok.template("head")
> bar.package2
> (no templates)
> from foo.package1 import HeadViewlet
> class HeadViewlet2(HeadViewlet):
>     pass
> However, looks like Grok doesn't liket the idea. 
> - Grok assumes templates are under "templates" which in my case happens to
> be Python package of the parent class. Grok does not look templates from
> there, but assumes bar.package2/templates which does not exist.
> - I cannot specify absolute templatedir (only relative paths allowed) with
> grok.templatedir() to force to use parent class template path
> Is there any other solution than just copying the same template around to
> every package?

This template inheritance issue is in the process of being fixed in 
martian, grokcore.component and grokcore.view.

It is a nasty problem and indeed until it is fixed we need to copy 
template files around. Souheil's solution kind of works arround it.

sorry for the inconvenience

More information about the Grok-dev mailing list