[Zope-DB] writing a template to test if the sql worked
charlie at egenix.com
Thu May 6 03:45:35 EDT 2004
On 2004-05-06 at 09:10:25 [+0200], Bogdan M. Maryniuck wrote:
> On Wed, May 05, 2004 at 11:08:26PM +0200, Dieter Maurer wrote:
> > While ZPT is slower than DTML it has less feature bloat and
> > is more orthogonal than DTML.
> > Therefore, it is easier than DTML.
As far as I recall there are two reasons why ZPT is slower than DTML:
1) DTML is already in optimised C code
2) ZPTs are more subject to Zope security checks
As these are both implementation issues it is reasonable to expect that ZPT
will get faster.
> But when you do really something advanced, you see your ZPT object is
> lots of <span tal:bla ... /> with omit-tag things. As result, you see your
> template object nor easier to read neither less complex in general.
Actually, I find that the examples in the Zope book lead to more complex
code than necessary. True a big ZPT will be complex but the code will
entirely be related to presentation, this is what Dieter means by orthogonal.
> Second: to get ZPT look good, you need separate your single DTML in dozen
> of PythonScripts
> and several ZPT objects. Does it makes life more easy?
Absolutely! It encourages modularity, structure and code reuse: my
presentation code does, my data access code does that, my procedural code
> Third: I found in general when you do DTML, this is much less to write.
> Other funny thing is: ZPT invented for people to get Zope more easy.
> Ironically, DTML
> still more easy and more simple...
Only to get going. ie. <dtml-var> as opposed to <block metal:use-macro> for
reusing bits of code. Once you get onto more complicated stuff DTML just
gets surreal and painful.
I found the transition from DTML zo ZPT a little difficult myself but once I
understood that anything more complex than a Python statement was best
passed to a Script I never looked back. In fact I would refer to a thread
from April 2004 and particularly Jim Penny's mails re. doing all the hard
stuff in scripts:
mm, the particular mail I was thinking about seems to be missing.
> Clue: ZPT and DTML both are OK. The only different where you use it.
No, DTML and all other forms of inline scripting are inherently evil.
Speaking as a polyglot rather than a programmer: mixing database, procedural
and presentation code together is like mixing different natural languages
together and it is very easy to get mixed up and once that happens (and it
will!) it gets really difficult to work out what's actually being said.
More information about the Zope-DB