Пример #1
0
 def get_current_user(self, quizz_short_name):
     user_uuid = __get_current_user_uuid(quizz_short_name)
     user = User.get_or_insert(key_name=user_uuid)
     if user.uuid == None:
         user.uuid = user_uuid
         user.lang = i18n.choose_lang(self.request.accept_language.best_matches(i18n.DEFAULT_LANG))
     return user
Пример #2
0
 def render_template(self, template_file, dictionary = {}):
     if not dictionary.has_key('lang'):
         # load lang from user prefs => make user a class attribute ?
         # otherwise, fallback to the lang from the request headers :
         dictionary['lang'] = i18n.choose_lang(self.request.accept_language.best_matches(i18n.DEFAULT_LANG))
     template.register_template_library('app.web.templates_filters')
     path = os.path.join(os.path.dirname(__file__), '..', 'templates', template_file)
     self.response.out.write(template.render(path, dictionary))