[ZPT] Confused about Zope

Evan Simpson evan@4-am.com
Mon, 03 Mar 2003 11:25:25 -0600


<replace="options/x/sql:string"/>

If we're going to use TALES expressions to generate non-XML, non-HTML 
text, I would want the statement-level syntax to be a clean break with 
TAL.  The example above, while more concise than TAL, unnecessarily 
retains some of its features.  In particular, the "=" and trailing slash 
can be discarded.

Presumably, we aren't worried about XML-compliance, only human read- and 
writeability, and reasonably easy parsing.  Since we're talking about 
generic text generation, including JavaScript, CSS, Email, SQL, and who 
knows what else, there is no way that we're going to be able to come up 
with a syntax that "blends in" the way TAL does with XML.

Embedding TAL (or DTML) in HTML was able to take advantage of tags and 
their associated escaping convention (&lt;).  In generic text, we'd need 
to make up or adopt escaping rules and statement delimiters.  The 
tag/element structure of [X|HT]ML led to statement types that are not 
relevent here, such as "omit-tag" and "content".  XML restrictions on 
attributes, such as uniqueness and lack of ordering, also shaped TAL but 
may be discarded here. Once you have more than a little logic in your 
template, delimiting every bit of the logic becomes painful, and the 
idea of delimiting the literal text instead becomes appealing.

Fundamentally, we only need the following constructions: insert text, 
repeat text, handle exceptions, and conditionally omit text.  The 
ability to define variables would also be nice.  Here's a strawman:

color = path('options/color | nothing')
type_id = path('options/type_id | nothing')
"select * from products "
if color or type_id:
   " where "
if color:
   "color = " + path('color/sql:string')
if color and type_id:
   " and "
if type_id:
   "type_id = " + path('type_id/sql:int')

This is (almost) PTL, the templating language used by Quixote.

Of course, DTML has specialized tags for SQL and Email for a reason. 
It's much nicer to have a mini-language that enables you to write:

select * from products
<dtml-sqlgroup where>
   <dtml-sqltest color type=string optional>
<dtml-and>
   <dtml-sqltest type_id type=int optional>
</dtml-sqlgroup>

Frankly, DTML does quite a good job of all of this, if only it were more 
explicit and didn't have such a tall, jagged step between names and 
Python expressions.  If only it had TALES, say ;-)

Cheers,

Evan @ 4-am