[Zope] Best practices to write business apps?

Paul Winkler pw_lists@slinkp.com
Mon, 9 Dec 2002 15:01:24 -0800


On Mon, Dec 09, 2002 at 09:50:22PM +0100, Frederic Faure wrote:
> I'm back to playing with Zope, except this time I need it as a tool to 
> rewrite business apps (payroll, in this case.) I've read the New Riders 
> book along wit the online Zope Book. I understand that DTML is evil and 
> that new users should prefer ZPT.

I wouldn't say that DTML is evil... simple DTML is very nice,
it's just that *abuse* of DTML is evil and it's always tempting
to add just "one more thing" instead of breaking it out into
a script.  And you can abuse ZPT pretty easily, too...
tal:define and tal:condition and tal:repeat give you plenty of
rope. It's somewhat more explicit rope than some of the magic 
DTML stuff, and there's a lot less of it; but you can still hang 
yourself with it. :)
 
> Anyway, is there a good document for newbies that come from procedural 
> languages like VB that would show them how to get up to speed?

The "Advanced Scripting" chapter in the online Zope book is a decent
introduction to this kind of thing, although it's a lot more
nuts-and-bolts than best-practices.  I said *introduction*...
it has little examples of forms that are processed
by scripts that can call other scripts, etc.

Since you say "procedural languages", I suspect what you
really need is to read this:
http://www.zope.org/Members/mcdonc/HowTos/gainenlightenment

Again, it isn't exactly what you asked for - it's heavy on
rah-rah and contains no real "how do I..." stuff. But it will
get you in the right mind-frame.

> I need to 
> understand how to separate logic and presentation as cleanly as possible. 

Object orientation will help you here. Remember what
the Extreme Programming guys say: "Refactor mercilessly". 
When you see some logic in your presentation templates,
ask yourself, "What is the maximum amount of this logic
that I can break out into a separate script?
what is the absolute minimal amount of logic that I can have 
in this template and still get the job done?"  

For example, look at the code in a tal:condition="..."
statement.  Do you have to do a bunch of tal:defines
just to set up the condition? Do you have nested tal:conditions?
Can you put all that stuff in one python script and 
in this template just have tal:condition="here/myscript"?
These are the kind of low-level questions you can ask yourself.  


As far as architecture of your app... big topic. TOO big.
"It depends." 


-- 

Paul Winkler
http://www.slinkp.com
"Welcome to Muppet Labs, where the future is made - today!"