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

Lennart Regebro regebro at gmail.com
Thu Nov 1 11:40:27 EDT 2007

On 11/1/07, Brandon Craig Rhodes <brandon at rhodesmill.org> wrote:
> In other languages - but this might not be Pythonic? - one would
> provide class-method constructors that could each satisfy a different
> factory interface, without extra (and thus "silly") parameters.  Like:
>     class GrokFileTemplate(...):
>         @classmethod
>         @directlyProvides(IFilePageTemplate)
>         def from_file(cls, path):
>             ...
> That way one does not wind up creating an entire class, just to give
> it a single __call__ method.  That's what functions are for. :-)

That's an option. The other option is to actually have two classes.
One being the FileTemplate factory, and the other the template itself.
That is still two classes, but on the other hand, bit classes are
simple and easy to understand.

With my current solution, the FileTemmplate it's a bit "stocky". And
with your proposed solution here, it gets even stockier, and there is
a lot of advanced python magic going on.

I'm currently leaning towards having a separate factory again, but
merging the file template and inline template.

Lennart Regebro: Zope and Plone consulting.
+33 661 58 14 64

More information about the Grok-dev mailing list