[Grok-dev] trying to inherit grok.template

Kevin Smith kevin at mcweekly.com
Thu Jun 26 13:18:36 EDT 2008

Until there is a real solution, here is an ugly workaround...

class MyView(grok.View):
   def render(self):
# render needs to be defined, but if a template exists it will be called 

I haven't had time to propose a real solution. You can look at __call__ 
to see why this works.


Kevin Smith

Ivo van der Wijk wrote:
> Hi,
> I'm confused by how grok.template() works with inheritance. What I
> want is a baseclass that implements a generic way to list objects in a
> container with an associated template. Specific context
> implementations should derive from this and reuse the template that's
> bound to the base listing.
> This works with render(), but it doesn't work with a template that's
> bound through grok.template() on the baseclass - grok will complain
> there's no associated template or render method.
> I know grok.AddForm does something similar - what's the trick?
> Regards
> Ivo

More information about the Grok-dev mailing list