24 Sep
2001
24 Sep
'01
7:26 p.m.
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