From bcc2f620dbf67230c25fdc4da487e22dfab9a805 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 29 Sep 2015 14:46:48 +0200 Subject: [PATCH] [FIX] website: `geoip` not defined in session for invalid session The method that set `geoip` in the session, `_geoip_resolve`, is called just before `self._authenticate`, which logout the user when the session is invalid, and therefore reset the session. Therefore, `geoip` could not be in the session in that place. This isn't that bad, as, at the next request, the `geoip` will be correctly set in the session. During the analysis of this issue, we observed that the reset of the session is actually not saved, because the save of this session is done in `Root.get_response`, through the call `self.session_store.save(httprequest.session)`, but `Root.get_response` is not called in `Root.dispatch` in case of HTTPException (500 internal server error in this case). This might need to be changed, to do the session save with a finally in this `Root.dispatch` method, so the above bug could have been resolved with a simple refresh (which would have re-defined the `geoip` in the session). opw-650416 --- addons/website/models/ir_http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/models/ir_http.py b/addons/website/models/ir_http.py index f636483864e..11db1070ea2 100644 --- a/addons/website/models/ir_http.py +++ b/addons/website/models/ir_http.py @@ -162,7 +162,7 @@ class ir_http(orm.AbstractModel): return self.reroute('/'.join(path) or '/') if not request.context.get('tz'): - request.context['tz'] = request.session['geoip'].get('time_zone') + request.context['tz'] = request.session.get('geoip', {}).get('time_zone') # bind modified context request.website = request.website.with_context(request.context)