|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
grok.template() and inheritance, Was: trying to inherit grok.templateHi,
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? regards, jw _______________________________________________ Grok-dev mailing list Grok-dev@... http://mail.zope.org/mailman/listinfo/grok-dev |
|
|
Re: grok.template() and inheritance, Was: trying to inherit grok.templatePerhaps this is completely unrelated but I've noticed another pitfall.
class Dad(grok.View): # see dad.pt def get_calculation(): ... class Son(Dad): 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. Peter 2008/8/5 Jan-Wijbrand Kolman <janwijbrand@...>: > Hi, > > 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? > > > regards, > jw > > > _______________________________________________ > Grok-dev mailing list > Grok-dev@... > http://mail.zope.org/mailman/listinfo/grok-dev > -- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com _______________________________________________ Grok-dev mailing list Grok-dev@... http://mail.zope.org/mailman/listinfo/grok-dev |
| Free Forum Powered by Nabble | Forum Help |