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

Brandon Craig Rhodes brandon at rhodesmill.org
Thu Nov 1 13:43:35 EDT 2007


"Lennart Regebro" <regebro at gmail.com> writes:

> 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.

There is, indeed, a bit of magic in my solution; in it, we have to
look up whether they've defined an "extension" class variable on their
new template class, and if they, have then we register the from_file
factory class-function they've inherited from our base class as a
utility that our template-directory-scanner will be able to use.

But in return for that magic we get two things.  First, we've
simplified the task of the person plugging in a new template engine;
and so far, that's all I've been hyping: "But it makes it a few lines
*easier* for them", with a big grin on my face. :-)

But now I'll bring up a second, and much more serious, advantage: by
doing the utility registration ourselves, rather than making each
template plugger create their own facotry utility class, we hide an
important implementation detail and therefore allow ourselves to
improve or adjust the mechanism later!  If we realize later that want
an explicit template-extension registrar rather than a series of
utilities; or that we want the utilities local in some circumstances
and global in others; or that we want localness or globalness being
configurable by the end-user; then we can, because we've kept control
of how the whole thing works.  I like that idea. :-)

-- 
Brandon Craig Rhodes   brandon at rhodesmill.org   http://rhodesmill.org/brandon


More information about the Grok-dev mailing list