[Grok-dev] grok.template() and inheritance,
Was: trying to inherit grok.template
peter at fry-it.com
Tue Aug 5 10:35:10 EDT 2008
Perhaps this is completely unrelated but I've noticed another pitfall.
# see dad.pt
def get_calculation(): ...
def render(self): # will never be called
return "manual render() " + self.get_calculation()
When you publish the view 'son' it be spotted as one having a template
already, thus omitting it's explicit render method.
I made this mistake myself and got confused. In the end I introduced a
baseclass view and put get_calculation() in that instead.
2008/8/5 Jan-Wijbrand Kolman <janwijbrand at gmail.com>:
> Somewhere in June Ivo wrote:
>> 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?
> Strange thing is, I remember reading this post at that time, but I somehow
> didn't appreciate the issue raised to its full extent.
> I do now.
> I think this really is a problem, as the behaviour for the `grok.template()`
> directive is counter intuitive *and* different from the behaviour of other
> directives such as `grok.context()` when subclassing view components.
> My proposal would be that `grok.template()` inheritance behaviour is fixed.
> I'll create a bug report in launchpad. I also volunteer to fix the problem -
> if we indeed agree this is an issue.
> So, is this indeed a bug in your opinion?
> Grok-dev mailing list
> Grok-dev at zope.org
More information about the Grok-dev