[Zope] Re: DTML Question

beno zope@thewebsons.com
Wed, 15 Jan 2003 03:49:49 -0400


At 12:20 AM 1/15/2003 +0100, you wrote:
>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...;)

Well, actually, that just made things a whole heck of a lot easier!!!
Thanks :)
beno