On Tue, Jul 23, 2002 at 06:17:45PM +0100, Ben Avery wrote:
I agree with Charlie, I think DTML has been designed not to make it easy to do any kind of business logic. Zope Page Templates are more recent, and have even less capacity for programming logic.
I think that was a deliberate decision, to encourage further separation of logic and presentation, possibly inspired by the recurring threads like "How do I do 10,000 things in my DTML document" which inevitably lead to some really confusing dtml code suggestions. Divide and conquer...
I'm newish to Zope myself, but for any development I do now, I only use DTML for presentation itself. For each page of the site I'm developing, I have a Python script, e.g. calendar_view_handler to take any form inputs from the previous page, use things from the session, call and use ZSQL methods, and put everything I need for the next page, in nice data structures into the request object, then call the DTML method, e.g. calendar_view_display, which only uses DTML variables to loop over data structures, and maybe do simple 'this or that' splits if I absolutely have to. This allows a clean separation of logic and presentation, and means you don't have this constant wrestle against the limitations of DTML. Using Python is actually a lot easier than using DTML - don't be scared by it, it's the easiest language to learn I've come across :)
Hear, hear. You're lucky that you got the idea early. I think many Zope newbies are put off by the thought of learning a templating language *and* a programming language. But it's really the right way to approach Zope. Everything becomes so much nicer. Remember, the O stands for Object... and any good object-oriented designer appreciates low coupling and high cohesion. Any Zope developers who don't recognize those phrases are highly encouraged to go look them up. Light bulbs will appear over your head when it sinks in. -- Paul Winkler home: http://www.slinkp.com "Muppet Labs, where the future is made - today!"