[Zope] dtml-if Newbie Question

Oliver Marx Oliver@tekk.dk
Tue, 05 Nov 2002 13:45:54 +0100


Alfredo P. Ricafort wrote:

> Hi,
>
> >From the 'Zope Book' the statement
>
>
>
> means that 'if the..variable does not exist, then this condition is
> false'.
>
> I found that this is not true.  When I tried using dtml-if to a
> non-existent variable, I got a 'key error'. So how do I check if the
> variable does not exist ?
>
> Tks.
>
> AL


Are you sure that you did not try:

<dtml-if expr="var_name">
	Something
</dtml>

Because it is *not* the same as:

<dtml-if var_name>
	Something
</dtml-if>

The first example is Python-like in behavior. You get a key error if 
var_name does not exist. The second example should work even if var_name 
is not defined AFAIK.

\Oliver