def locale_negotiator(request): """ Custom locale negotiator implementation. Obtain language from the current user's settings. If the user hasn't set preferred language, language is obtained from the 'Accept-Language' header. :param request: :return: """ user = User.by_id(authenticated_userid(request)) if user is not None and user.language is not None: return user.language for language in request.accept_language: language = language.split('-')[0] if language in supported_languages: return language return default_language
def update_user_timestamp(self): ixiacrlogger.debug('Entering: update_user_timestamp') #ixiacrlogger.info(str(self.request.cookies)) #ixiacrlogger.info(str(self.request.cookies.get('auth_tkt'))) self.messages = [] ixiacrlogger.debug(str(self.request.cookies.get('auth_tkt').split('!')[0])) try: user = User.by_id(self.user_id) if user: if user.session_id != self.request.cookies.get('auth_tkt').split('!')[0]: #return HTTPSeeOther(route_url('logout', self.request)) return {'result': 'FAILURE'} else: user.update_session(user.session_id, user.remote_addr) return {'result': 'SUCCESS'} except Exception, e: ixiacrlogger.exception('IxiaUtilHandler: update_user_timestamp: %s' % e) self.messages.append({'header': 'Failed', 'content': str(e)}) return {'result': 'FAILURE', 'messages': self.messages}