[ZPT] Confused about Zope
Evan Simpson
evan@4-am.com
Mon, 03 Mar 2003 12:18:49 -0600
Shane Hathaway wrote:
> The idea I was going on, though, is to *avoid* breaking from TAL--I
> wanted people to learn TAL then reuse those skills for non-XML.
I suggest that TAL (as opposed to TALES) is so *small* that there is
very little knowledge there worth transferring to another domain.
> That's a very convincing example. So non-XML TAL won't work for this.
Well, that's a bit strong. My strawman worked for this, it was just
awkward and ugly :-) My point was really that extensibility to
mini-languages is a very nice feature; we could probably develop it for
text-TAL, but it isn't obvious how.
> Just for kicks, though, imagine using XML to generate SQL.
...
> Forget it. Never mind. :-)
On a side note, I've frequently though about generating SQL using Python
helper classes, much like HTMLgen. A great deal of the unpleasantness
of templated SQL has to do with things like lists that don't tolerate
trailing commas (despite mandatory surrounding parens), separate but
coordinated lists of names and values (INSERT), and keywords such as
'where' that should only appear if their "section" is non-empty.
I start thinking along these lines:
s = Delete("addresses")
s.where = w = Where()
if state:
w.add(Field("state"), "=", Value(state))
if zip:
w.add(Field("postcode"), "=", Value(zip))
if w:
w.add(Or(Not(Field("current")),
(Field("status"), "containing", Value("x")))
...but I quickly get discouraged by the verbosity and complexity that
seems to be required to do it correctly.
Cheers,
Evan @ 4-am