On Saturday, December 7, 2002, at 04:11 AM, Tino Wildenhain wrote:
Hi Chris,But SQL Method DTML is very very very very nice. It has a lot of type enforcement/safety measures (ie - autoquoting SQL Strings, ensuring that a 'sqlvar type=float' operation is inserting a float); a lot of *very* nice features for generating 'where' clauses (the sqltest 'optional' flag and the smart '<dtml-and> and <dtml-or>' tags that won't render if an optional 'sqltest' preceding them was not rendered); the 'sqltest multiple' feature is especially nice:
--On Freitag, 6. Dezember 2002 21:27 -0500 Chris McDonough <[EMAIL PROTECTED]> wrote:
<dtml-sqltest foo type=nb multiple optional>
If foo is a blank string or empty list, that will render nothing.
If foo is a single string, that renders::
where foo = 'bar'
But if foo is a list of strings, that will render::
where foo in ('bar', 'baz')
Doing that programatically in Python is counterintuitive and awkward (just as it was before the specialized 'dtml-sql___' tags in DTML). For simple queries, doing it in the host programming language is not bad. But for complex queries, it's very awkward to generate SQL. It's almost as bad as generating HTML inside of a programming language - it becomes difficult to maintain.
I wouldn't mind seeing DTML.String re-emerge, which complements the Python formatting string with DTML constructs to handle more advanced templating needs. If you took a lot of the programming-language style tags (dtml-try, dtml-return) out of DTML and normalized the expression system (ie - to use TALES), you'd have a very usable system. The core design concepts of DTML are good, it's just corrupted itself over the years by stepping out of the plain-text templating language domain and straddling the templating/programming language domains. DTML is even used to generate DTML, by using the Extended Python Format String syntax. This is how the 'Z Search Interface' custom reports are generated.
Life would be so much better if odd tags like <dtml-sendmail> could just go away, and instead we had 'SMTP Methods' or something like that - mail specific templates that are bound to a mailhost, with special DTML tags (like the mime tag), similar to SQL Methods.As a general solution for texts one can use "file" which has an edit tab for several releases of zope now. Then use it like this:context.thefile.read() % context.REQUEST.form or whatever seems appropriate to get values from. E-Mail even gets clearer with the solution since you can easyly loop and do whatever instead of multiple <dtml-sendmail> tags.
I love the SQL Method specific DTML tags. They make writing dynamic SQL statements so easy, especially when compared to _any_ other system that I've seen. It's a good showcase for DTML's ability to turn into a domain specific templating language.
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists - http://lists.zope.org/mailman/listinfo/zope-announce