On Fri, Jan 18, 2008 at 04:35:58PM +0100, Malthe Borch wrote:
> Getting back to the monkey, perhaps it would make sense to formalize the
> way a template object gets its source file. The template class could
> adapt to an ``IFileSource`` implementation that would provide a filename.

What about zope.pagetemplate.interfaces.IPageTemplate?

Personally I like the way z3c.form.form.BaseForm approaches this:

    def render(self):
        '''See interfaces.IForm'''
        # render content template
        if self.template is None:
            template = zope.component.getMultiAdapter((self, self.request),
            return template(self)
        return self.template()

That way the template is just a multi adapter. I've made a zcml
directive that registers a template as just such a multi-adapter:

        for=".view.SomeView .interfaces.IMyLayer"
        bindings="view request"

"bindings" explicitly defines what names each of the adapted objects is
available as in the template. Because sometimes I don't only have a
context and request.

The only problem is that IPageTemplate is a bit heavy as an interface,
it would perhaps be nicer to have a parent interface that only defines a
__call__ method.

Brian Sutherland
Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to