[Grok-dev] Re: first thoughts on "regebro-guido-templates"

Lennart Regebro regebro at gmail.com
Tue Oct 30 13:18:33 EDT 2007


On 10/30/07, Martijn Faassen <faassen at startifact.com> wrote:
> Hey,
>
> On 10/30/07, Lennart Regebro <regebro at gmail.com> wrote:
> > On 10/30/07, Martijn Faassen <faassen at startifact.com> wrote:
> > > True, I hadn't considered that. What about introducing a new method
> > > that does the combination, so that there's no requirement for the
> > > person writing the plugin anywhere?
> >
> > So you mean something like this:
> >
> > class MyTemplate(object):
> >
> >     def namespace(self, view):
> >         return {'request': view.request,
> >                      'view': view}
> >
> >     def getNamespace(self, view):
> >         return self.namespace(view).update(view.namespace())
> >
> >     def render(self, view):
> >         return  self._template.render(**self.getNamespace(view))
> >
> > Where getNamespace would be the new method you talk about (and
> > normally defined only on the baseclass)?
>
> Excatly. This would keep both namespace() and render() without special
> knowledge concerning dictionary construction. The only thing extra to
> explain is that people typically shouldn't override getNamespace()
> themselves (perhaps in a docstring in the interface).

OK, let's go for that.
-- 
Lennart Regebro: Zope and Plone consulting.
http://www.colliberty.com/
+33 661 58 14 64


More information about the Grok-dev mailing list