[ZPT] Confused about Zope

Shane Hathaway shane@zope.com
Mon, 03 Mar 2003 12:49:16 -0500


Evan Simpson wrote:
> <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.

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.

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

Yuck. :-)  PTL is a curiosity, BTW--you could write PTL in pure Python 
if you're willing to prefix the output strings with a "print" statement.

> 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 ;-)

That's a very convincing example.  So non-XML TAL won't work for this.

Just for kicks, though, imagine using XML to generate SQL.

select * from products
<where>
<and>
   <test column="color" type="string"
     tal:attributes="src options/color|nothing" />
   <test column="type_id" type="string"
     tal:attributes="src options/type_id|nothing" />
</and>
</where>

Forget it.  Never mind. :-)

Shane