[Zope] sqlgroup-if-and-else-or dilemma

TFE MMS JARVIS JOHN jarvis.sd082@ex.tel.co.jp
Wed, 8 Sep 1999 19:18:05 +0900


> That's it!!!!
> 
> Thank you! Thank You! Thank you!
> (but DANG! I should have thought of that ;^)
> 
> Now to see about that Zope 2...
> John Jarvis
> 
> -----Original Message-----
> From:	Martijn Pieters [SMTP:mj@antraciet.nl]
> Sent:	Wednesday, September 08, 1999 7:01 PM
> To:	TFE MMS JARVIS JOHN; zope@zope.org
> Subject:	Re: [Zope] sqlgroup-if-and-else-or dilemma
> 
> At 11:22 08/09/99 , TFE MMS JARVIS JOHN wrote:
> >Hi all,
> >   I'm trying to construct a search interface which allows users to
> >build a set of search conditions against a large DB view. One of the
> >requirements for this is that the users be able to choose between AND
> >and OR operators for each condition.
> >
> >   Something like (silly example...):
> >      Country = Japan
> >      and Area = Tokyo
> >      or Area = Kyushu
> >
> >   These conditions are converted to a where statement using DTML. The
> >problem is that Zope (still 1.10.3 :^(
> 
> Switch now, before it is too late! =)
> 
> 
> >  complains about unexpected
> ><!--#and--> and <!--#or--> tags within <!--#if--> blocks.
> >
> >   For example:
> >   <!--#sqlgroup where-->
> >   ...
> >   generated conditions
> >   ...
> >   <!--#if "LogOp=='AND'"-->
> >     <!--#and-->
> >   <!--#else-->
> >     <!--#or-->
> >   <!--#/if-->
> >    ...
> >    Another condition
> >   ...
> >   <!--#/sqlgroup-->
> >   doesn't work.
> >
> >   I guess the Zope internals weren't meant to handle this
> >construct. Has anyone been here before? Any ideas?
> >   Any suggestions would be greatly appreciated.
> 
> Hmm.. this indeed does not work at all, because that's not the way DTML
> works.
> 
> What you could do is this:
> 
>    <!--#sqlgroup where-->
>    ...
>    generated conditions
>    ...
>    <!--#and-->
>      <!--#if "LogOp=='AND'"-->
>        ...
>        Another condition
>        ...
>      <!--#/if-->
>    <!--#or-->
>      <!--#if "LogOp=='OR'"-->
>        ...
>        Another condition
>        ...
>      <!--#/if-->
>    <!--#/sqlgroup-->
> 
> Now, if your LogOp equals 'AND', then the 'and' block will actually be 
> used, because it contains output, but the 'or' block will not be used, 
> because it remains empty. And, of course, when LogOp equals 'OR', it will 
> be the other way around.
> 
> So, with LogOp == 'AND' you'll get:
> 
>    where ...generated conditions...
>    and ...Another condition..
> 
> and with LogOp == 'OR' you'll get:
> 
>    where ...generated conditions...
>    or ...Another condition..
> 
> which is what I think you want..
> 
> --
> Martijn Pieters, Web Developer
> | Antraciet http://www.antraciet.nl
> | Tel: +31-35-7502100 Fax: +31-35-7502111
> | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
> | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
> ------------------------------------------