[Zope] Re: silly DTML question: "in" test

Bill Seitz fluxent at gmail.com
Mon Dec 10 12:54:31 EST 2007

OK, here's a next rev that's close.

So I started out saying I have a url-arg value. Let's call that 'key'.

And note that foo_col is a boolean field.

So now zSql IfShowNextDoor contains
 SELECT foo_col FROM table where id=<dtml-sqlvar key type=int>

And then my DTML uses
 <dtml-call "REQUEST.set('z',IfShowNextDoor()[0][0])">

(I avoid dtml-let because when you need to do it multiple times, the
nesting of the lets gets ugly.)

This works (setting value as 0 or 1).

(thanks to all for earlier replies: I tried posting this update
earlier but it didn't go through somehow)

On Nov 28, 2007 1:20 PM, Bill Seitz <fluxent at gmail.com> wrote:
> I'm trying to do something in a DTML-Method (in ancient Zope 2.6.2)
> that seems like it should be really simple, but I can't get it right.
> I want to see if a value (defined via url-arg) is in a list which is
> generated from an RDBMS query (field type=integer).
> The pseudo-code would be something like:
> 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>
> But that doesn't work.

More information about the Zope mailing list