Fix get_locale() to make logout() work without traceback.

This commit is contained in:
Toshio くらとみ 2008-03-04 18:44:24 +00:00
parent 6879e07e72
commit 3326b99938

View file

@ -28,9 +28,14 @@ turbogears.view.variable_providers.append(add_custom_stdvars)
def get_locale(locale=None):
if locale:
return locale
if turbogears.identity.current.user_name:
username = None
try:
username = turbogears.identity.current.user_name
except AttributeError:
pass
if username:
person = People.by_username(turbogears.identity.current.user_name)
return person.locale
return person.locale or 'C'
else:
return turbogears.i18n.utils._get_locale()