[Zope] <dtml-var x missing> doesn't work?
Tino Wildenhain
tino@wildenhain.de
Wed, 29 Mar 2000 19:31:32 +0200
Hi Chris,
Chris Withers wrote:
>
> Hi,
>
> I'm doing a back link to go on a page (yes, I know browsers have back buttons, but some people don't
> like to use them ;-) which is easy enough:
>
> <A href="<dtml-var "REQUEST.environ['HTTP_REFERER']">">Back</A>
>
> except that if there is no referer, you get a key error. So I thought I'd try the following:
>
> <A href="<dtml-var "REQUEST.environ['HTTP_REFERER']" missing='/'>">Back</A>
>
> But I still get a key error. I thought the 'missing' attribute was supposed to catch that?
This counts only for something like <dtml-var ought_to_be_missing
missing>
In your case you are inside Python when calling with " ".
So "missing" cannot catch this exception.
(Actually this simple <dtml-var .. > does much magic :)
So in your case you should do:
<dtml-if "REQUEST.environ.has_key('HTTP_REFERER')">
<A href="<dtml-var "REQUEST.environ['HTTP_REFERER']">">Back</A>
</dtml-if>
This has the advantage of no blind link if there is no HTTP_REFERER set.
Hth
Tino Wildenhain