[Zope] <dtml-var x missing> doesn't work?

Chris Withers chrisw@nipltd.com
Thu, 30 Mar 2000 11:51:35 +0100


>    Not quite. You are tripping a key error here so that won't work. Try:

Sorry to be picky here but, quoting from Table 15 on page 21 of the DTML Guide:
missing - Provide a value to be used if the ariable(sic) is missing, rather than raising a KeyError.

> <dtml-if "REQUEST.has_key('HTTP_REFERER')">
>    <dtml-var "REQUEST['HTTP_REFERER']">
> </dtml-if>

This is what I ended up doing :-)

Is it just me or does it seem silly that:
<dtml-var HTTP_REFERER missing='/'>
works as expected but
<dtml-var "REQUEST.environ['HTTP_REFERER']" missing='/'>
doesn't, even though they're logically the same thing?

The KeyError should be caught when evaluating the expression as well as the name in dtml-var :(

I might chuck this in the collector at some stage...

Chris