[Zope-DB] dynamic SQL

Fernando Martins fmartins@hetnet.nl
Thu, 10 Apr 2003 23:53:15 +0200


Jim Penny wrote:
> I wrote a howto on doing this.  This is a common idea _many_ new users
> have.  I now deeply wish that I had not done so.  This is very bad
> magic.  It makes your life unpleasant for an unforseeable time in the
> future.  And when you are prototyping is exactly the wrong time to do
> it!  The problem is that you then have an unauditable mess that can be
> fixed only by throwing everything away.
>

Yes, I think this is already clear when I'm analysing the combinations of
queries I can get. Obviously, maintain the code which concatenates all the
pieces of statements will be too expensive.

> I recommend that you do things in little steps.  Start writing your
> application in ZPT (or DTML) and pythonscripts.  Every time you need a
> SQL query, go off to the side, and write it.  Test it from the SQL test
> tab.  That way you are reasonably confident that it works before you put
> it in the ZPT.  Put it in the ZPT.  test again.  Flesh out the ZPT.
> Test again.
>
> One of the most pleasant parts of zope is the ease of continuous,
> informal, samll testing.  Oh, things will get past you, but if you test
> as you develop, a lot less gets past you.  I often test every time I
> create a new table row, or paragraph, or whatever.
>

Thanks, when I received your message it turned out clear this is the way to
go.

I would summarise by saying this is a matter of separating business logic
(decide which queries are needed) from data management (how to access the
data).

Cheers,
Fernando