Hi, is it also possible to have an or clause in a dtml-if. The following didn't work: <dtml-if expr="_.has_key('nol') and nol=='root' or nol==''"> ... </dtml-if> How do I add an or to a dtml-if? Thanks in advence Erwin
search for "Odbc" on zope.org. -aj --On Dienstag, 13. Mai 2003 11:22 Uhr +0200 "n.a.s" <naus.office@aon.at> wrote:
Hi,
is it also possible to have an or clause in a dtml-if.
The following didn't work:
<dtml-if expr="_.has_key('nol') and nol=='root' or nol==''"> ... </dtml-if>
How do I add an or to a dtml-if?
Thanks in advence
Erwin
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
On Tuesday 13 May 2003 11:22, n.a.s wrote:
Hi,
is it also possible to have an or clause in a dtml-if.
The following didn't work:
<dtml-if expr="_.has_key('nol') and nol=='root' or nol==''"> ... </dtml-if>
Doesn't it work with braces ?? <dtml-if "_.has_key('nol') and (nol=='root' or nol=='')"> ... </dtml-if> Thierry -- Linux every day, keeps Dr Watson away... http://gpc.sourceforge.net -- http://www.ulthar.net
Thierry FLORAC wrote:
On Tuesday 13 May 2003 11:22, n.a.s wrote:
Hi,
is it also possible to have an or clause in a dtml-if.
The following didn't work:
<dtml-if expr="_.has_key('nol') and nol=='root' or nol==''"> ... </dtml-if>
Doesn't it work with braces ??
<dtml-if "_.has_key('nol') and (nol=='root' or nol=='')"> ... </dtml-if>
Thierry
Sorry, it works (my fault). But how can I test of non existens of nol. I would need something like <dtml-if "_.has_key('nol') and (nol=='root' or nol=='' or !nol)"> Thanks Erwin
On Tue, 2003-05-13 at 07:02, Erwin Ambrosch wrote:
But how can I test of non existens of nol.
When the name is what's being evaluated, non-existence evaluates as a false value. Thus: <dtml-unless nol> Stuff to do if nol is false, empty, or doesn't exist. </dtml-unless> or <dtml-if nol> Stuff to do if nol exists and is true / non-empty </dtml-if> That's not exactly what you asked, but... HTH Dylan
On Tuesday 13 May 2003 07:02 am, Erwin Ambrosch wrote:
But how can I test of non existens of nol. I would need something like
<dtml-if "_.has_key('nol') and (nol=='root' or nol=='' or !nol)">
If it "doesn't exist" then _.has_key('nol') would've evaluated false, and none of the rest of the statement matters. If it *does* exist, but is equal to a false value -- '', None, (), [], or 0 -- then "not nol" will be false (you don't want "!" -- that's either meaningless or a bitwise NOT, I can't remember, but not a logical NOT). Remember: python uses words to do logic and symbols to do math. (Actually I don't know if that's rigorously true, but it's a good rule of thumb for remembering how to do "if" expressions ;-) ). So you can probably write that: <dtml-if expr="_.has_key('nol') and (nol=='root' or not nol)"> or maybe you meant: <dtml-if expr="not _.has_key('nol') or not nol or nol=='root'"> which seems more logical: this will evaluate to true if there is no "nol" name, the name maps to a false value, or to the special value "root". Any other value will be false. My guess is that this is what you meant -- but only you know what you want. ;-) HTH, Terry -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com
participants (6)
-
Andreas Jung -
Dylan Reinhardt -
Erwin Ambrosch -
n.a.s -
Terry Hancock -
Thierry FLORAC