[Zope] String compare

Passin, Tom tpassin@mitretek.org
Tue, 13 May 2003 13:16:46 -0400


[n.a.s ]

> I can't compare a String with a dtml-var variable.

> <dtml-if expr=3D"REQUEST.has_key('nol') and nol=3D=3D'<dtml-var id>'">

Of course you can do a compare, but not with invalid syntax.  The
<dtml...> tag just sets up the environment for accessing objects, and
there is no need to try to stick another <dtml> tag inside one (even if
it were allowed).

All you need is the obvious -

<dtml-if expr=3D"REQUEST.has_key('nol') and nol=3D=3Did">

Furthermore, Python uses short-circuit evaluation, so the expression
will not fail if there is no key for nol - very helpful.

Cheers,

Tom P