[Frank Tegtmeyer]
"Thomas B. Passin" <tpassin@mitretek.org> writes:
If you don't want to have the possiblity of an empty <ul> element, you could write
<dtml-let List=Python_script> <dtml-if List> <ul> <dtml-in List> ... </dtml-in> </ul> </dtml-if> </dtml-let>
Yes, that's definitely cleaner. Does it double the necessary storage for the list? I think dtml-in has to have the list in memory to provide it's attributes. If the list is huge this may be a problem, but in this case dtml-in is a problem by itself anyway.
I don't think that it doubles. In <dtml-in List>, List is only a reference to the variable List that was created in the <dtml-let>, it's not a copy (I'm "sure" but don't truly know how Zope implements dtml-in. I've always thought that it's based on Python's "for a in b" construction). That is, there is only one instance of List. And it's better to create it using dtml-let because then it will go away when the page is done, whereas using REQUEST.set() is said to lead to memory leaks on occasion (apparently some references to the REQUEST may remain somewhere else, preventing garbage collection). Now if you had used Python_script (instead of List) both in dtml-if and dtml-in, you __would__ have incurred both the memory and the time to create the object twice. That's why I created List, so it only has to be done once. Cheers, Tom P