[Zope] Testing multiple values for existance - still
Dieter Maurer
dieter@handshake.de
Mon, 24 Sep 2001 21:26:28 +0200 (CEST)
Oliver Sturm writes:
> I recently had the following question:
>
> > I can do <dtml-if foo> to test if foo is known at all. Why can't I do
> > <dtml-if "foo or bar"> to test if either foo or bar are known? I get a
> > "Name Error" saying something like "global name 'foo' is not defined" if I
> > do this (and foo is actually undefined). Is there a different syntax for
> > this?
>
> which was answered quickly by marc lindahl <marc@bowery.com> with
>
> > Try testing for existence first -- hasattr()
>
> and by Steve Drees <drees@rangebroadband.com> with
>
> > <dtml-if "REQUEST.has_key('foo') or REQUEST.has_key('bar')">
Apparently, you ignored my reply.....
<dtml-if "(_.has_key('foo') and foo) or (_.has_key('bar') and bar)">
Dieter