[Zope] silly DTML question: "in" test
Garry Saddington
garry at schoolteachers.co.uk
Wed Nov 28 14:31:38 EST 2007
> if foo in (select foo_col from table where x=y)
> then z='t'
> else z='f'
>
> I tried putting the simple SELECT query into a zSql and then calling it
> like:
>
> <dtml-call "REQUEST.set('foo_list',IfShowNextDoor())">
> <dtml-if expr="foo in foo_list">
> <dtml-call "REQUEST.set('z','t')">
> <dtml-else>
> <dtml-call "REQUEST.set('z','f')">
> </dtml-if>
How about checking the database table for foo rather than the result set:
ZSQL method name=select
argument=foo
select foo_col from table where foo_col =<dtml-sqlvar foo type="string">
then do:
<dtml-in select>
<dtml-call "REQUEST.set('z','t')">
> <dtml-else>
> <dtml-call "REQUEST.set('z','f')">
> </dtml-in>
If the variable is in table then dtml-in returns a result set and the
<dtml-call "REQUEST.set('z','t')"> is called, if not the dtml-else is called.
HTH
Regards
Garry
More information about the Zope
mailing list