[Zope] Re: DTML Question

Maik Jablonski maik.jablonski@uni-bielefeld.de
Wed, 15 Jan 2003 00:20:51 +0100


Passin, Tom wrote:
> BTW, I would simplify (just shorter and easier to read, not otherwise
> better) these lines:
> 
> <dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')">
> 
> to
> 
> <dtml-let lang="REQUEST['HTTP_ACCEPT_LANGUAGE']">

Hi,

I'm not sure, if the second solution should be recommended at all... If 
HTTP_ACCEPT_LANGUAGE is not set in the REQUEST at all, 
REQUEST['HTTP_ACCEPT_LANGUAGE'] will raise an key-error, while the first 
one still works. lang will be simply None this way. Maybe even better is:

<dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE','en')">

So lang "defaults" to a 'en' as 
standard-language-if-no-other-language-is-given and your further code 
won't break if lang is None...;)

Cheers, Maik