On Thu, 2003-07-17 at 13:04, Bryan White wrote:
I suspect my bad habits are coming from my scripty background rather than anything else. I am spoiled by creating and discarding variables arbitrarily in basically procedural code. So, if I have a mess like:
1. Some DTML stuff to make logical decisions 2. Some unrelated stuff 3. Some more DTML that depends on the decisions made in step 1
The Zope way is more like this: 1. Use objects to store and retrieve data. 2. Use Python (scripts or ext. methods) for logic 3. Use ZPT or DTML to obtain results from 1 or 2 and display them 4. Use acquisition to integrate 1-3 DTML and TAL have logical constructs, but this shouldn't be confused with them being good tools for actual logic. The heaviest logic you should probably be doing with templates is iterating over result sets and determining how/if results should be displayed. Ex: <UL> <dtml-in some_sequence prefix=my_seq> <dtml-if my_seq_item> <!-- my_seq_item is non-False / non-empty --> <LI><dtml-var my_seq_item></LI> </dtml-if> </dtml-in> </UL> Note that some_sequence (your result set) is probably the id of some other object such as a script, external method or ZSQL method. Although it *could* be a variable you set earlier in DTML, that's a less common usage. Typically, you use Python and/or ZSQL to do any heavy lifting required to *create* a result set and to use templating for little more than obtaining & formatting the results. As a variation, what if you *do* have to pass something to get the proper result set? You'll have something like this: <dtml-in "some_sequence(name)"> Where 'name' has some obtainable value in the current context. Assuming that the 'some_sequence' object can accept this argument, it will do whatever it's supposed to do and return a result set for the DTML to iterate over & format. That's 99% of all there is to it. I hope that helps you over the conceptual hump. Zope is much harder to use when you don't buy into the way it's designed to be used. If at all possible, I'd suggest ditching the procedural/scripty approach. HTH, Dylan