8 caractères requis pour un mot de passe.
[Plinn.git] / Products / Plinn / userlanguages.py
1 # -*- coding: utf-8 -*-
2 from zope.publisher.browser import BrowserLanguages
3 from Products.CMFCore.utils import getUtilityByInterfaceName
4 from zope.component.interfaces import ComponentLookupError
5
6 class AuthenticatedUserLanguages(BrowserLanguages):
7
8 def getPreferredLanguages(self) :
9 try :
10 mtool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
11 except ComponentLookupError :
12 return super(AuthenticatedUserLanguages, self).getPreferredLanguages()
13 if mtool.isAnonymousUser() :
14 return super(AuthenticatedUserLanguages, self).getPreferredLanguages()
15 else :
16 m = mtool.getAuthenticatedMember()
17 userLangs = m.getProperty('preferred_languages', [])[:]
18 return userLangs or super(AuthenticatedUserLanguages, self).getPreferredLanguages()