Web templating/db tool with best designer/coder separation?

Richie richie at entrian.com
Thu Jul 4 06:13:09 EDT 2002


> > The biggest problem I can see is that I'm using object attributes to
> > represent both HTML tag attributes and child objects.
> 
> I don't think this really is a big problem.

I think I agree.  The purist in me wants the two to be unambiguously
separated, but the pragmatist wants a simple API that lends itself to
intuitive code.

> I don't (yet) see the advantage of having different classes mirroring 
> the different HTML tags.

Only that certain tags could behave in friendly ways; the Input class
could know that its 'size' attribute is an integer, and return an integer
for its value rather than a string, for instance.  It's not necessary, and
could be too much black magic.

> Is there really a need for a DOM-like access where each tag and sub-tag
> of interest has to be tree-like identified?

No, not at all - the hierarchy would only include things with 'id' or
'name' attributes, so if you only needed to replace one thing you'd only
give that thing an 'id' attribute and it would be at the top of hierarchy.

If you do *need* a deep hierarchy, there's no reason you can't shortcut
straight to one element, as long its name is unambiguous:

>>> page = Template.Page( complicatedHtml )
>>> page.topsection.userinfo.loginform.username == page.getElement( 'username' )
True

Your "forest of sparse subtrees" idea (nice phrase!) is no problem.

> In a perfect world, we had even two layers of template substitutions: A
> 'low-level' one based one a Python API (like yours above), and a higher
> level one that specifies the substitutions in a more condensed way,
> (a little context-specific, mayve Quixote-like language).

I'm only really interested in what you call a low-level interface - two
languages, HTML and Python, are enough for me!  But I think the low-level
interface should work with any other interface - after all, it just takes
HTML, manipulates it, and outputs HTML.  There's no reason why the HTML
couldn't have come out of Quixote.

-- 
Richie Hindle
richie at entrian.com




More information about the Python-list mailing list