[Zope] a metric for killing DTML.

Florent Guillaume fg@nuxeo.com
1 Nov 2001 23:52:08 GMT


> Have other people found other useful rules of thumb about when
> to avoid DTML? 

My guidelines are that dtml is only allowed to do
	<dtml-with somename>
	<dtml-with "somename(arg,arg)">
	<dtml-in somelist mapping>
	<dtml-if somename>
	<dtml-var somename> or &dtml-somename; and variations
	<dtml-var sometemplate>
and that's it. Especially, ANY computation of any sort is forbidden.

For every dtml page "mypage" that I have, there is a script "mypage_get"
which computes everything, puts it in a a big datastructure (usually a
mix of imbricated dictionnaries and lists) and it's called from a
dtml-with at the beginning of the dtml page (maybe with parameters).
The use of the "mapping" idiom in dtml-with or dtml-in is
very very useful.

As Seb Bacon mentionned, I still have some REQUEST.set at the beginning
of some pages, to initialize variables used in other dtml, but that's
because not everything was designed properly I think.

Of course I break those guidelines in many occasions, but at least I
know I do it and I feel bad about it :)

Besides this styles is very straightfoward to translate to ZPT, which is
no small advantage.


	-- Florent
-- 
Florent Guillaume, Nuxeo SARL (Paris, France)
+33 1 40 33 79 10  http://nuxeo.com  mailto:fg@nuxeo.com