[webrequest] simplify set_session code
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Mon, 24 Jun 2013 11:31:47 +0200
changeset 9041 753a159c8822
parent 9040 3c85e734ce00
child 9042 6cc13a0a9145
[webrequest] simplify set_session code Thanks to the previous changeset we are assured that session handed to set_session is full featured one. This allows a simpler code for this method. related to #2503918
web/request.py
--- a/web/request.py	Fri Jun 21 16:28:16 2013 +0200
+++ b/web/request.py	Mon Jun 24 11:31:47 2013 +0200
@@ -225,16 +225,10 @@
         """
         super(CubicWebRequestBase, self).set_session(session)
         # set request language
-        vreg = self.vreg
-        if self.user:
-            try:
-                # 1. user specified language
-                lang = vreg.typed_value('ui.language',
-                                        self.user.properties['ui.language'])
-                self.set_language(lang)
-                return
-            except KeyError:
-                pass
+        user_lang = self.user.properties.get('ui.language')
+        if user_lang is not None:
+            lang = self.vreg.typed_value('ui.language', user_lang)
+            self.set_language(lang)
 
     # input form parameters management ########################################