[Zope3-dev] Re: [Zope-DB] Relational Databases in Zope 2 and Zope 3

Charlie Clark charlie at egenix.com
Tue Jun 29 05:54:26 EDT 2004


On 2004-06-29 at 10:22:14 [+0200], "Smith, Neil (Worcester)" 
<Neil.Smith at npower.com> wrote:
> The point of the dtml-sqlgroup and dtml-sqltest is surely to provide a nice
> way of handling the case where you don't pass in the parameter, so it
> doesn't render the WHERE, AND, = etc.  And it does this quite well.

Maybe it does. I've never found cause to use it and scratched my head a lot 
trying to look at it. I'd hate to maintain such stuff something which Ian 
Bicking seems to complain about.
 
> If you remove it, then you'll need either an exponential number of SQL
> methods and some logic before it to decide which to call, or you'll have to
> fill the SQL method with even more confusing dtml-if statements, or you'll
> have to have your SQL something like:
> 
> WHERE (
>    <dtml-sqlvar parameter_1 type=..> is null or
>    column_1 = <dtml-sqlvar parameter_1 type=..>
> ) and (
>    <dtml-sqlvar parameter_2 type=..> is null or
>    column_2 = <dtml-sqlvar parameter_2 type=..>
> )

Interesting example. This says to me that the model is bad: NULLs are 
indicative of this. It's also intriguing that to see the relation variables 
passed in as relation values. I think this will probably cause an error on 
rendering. Okay, so nit-picking aside: you are right to say that <dtml-if>s 
can cause problems on larger methods. I find that readibility is still there 
but I get problems when I might only want to return a certain value based on 
something I'm passing in. Working on my larger ZSQL methods has reminded me 
of working on HTML pages which is why I find ZPT attractive.

I think what might be the biggest problem is the lack of good examples on 
this. The stuff in Zope book does not seem to me to be written with real 
world experience so maybe you've got a concrete example with the resultant 
SQL for us to discuss?

Charlie


More information about the Zope-DB mailing list