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

Petru Paler ppetru@coltronix.com
Wed, 29 Mar 2000 20:05:15 +0300


On Wed, Mar 29, 2000 at 05:42:55PM +0100, Chris Withers wrote:
> 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?

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

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

-Petru