From ef10c2e3c84bc929945fcf1890202c7f7842c9cb Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 28 Feb 2013 18:35:30 +0100 Subject: [PATCH] [FIX] http.WebRequest: clear db/uid tracking on worker thread to avoid incorrect values during logging Could happen when a worker thread is reused for another database but does not go through all the dispatching levels, e.g. for static resources served by werkzeug itself. bzr revid: odo@openerp.com-20130228173530-bs5pun9o09iobosi --- addons/web/http.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/web/http.py b/addons/web/http.py index 8595e38446f..5bc5388df8d 100644 --- a/addons/web/http.py +++ b/addons/web/http.py @@ -93,6 +93,14 @@ class WebRequest(object): if not self.session: self.session = session.OpenERPSession() self.httpsession[self.session_id] = self.session + + # set db/uid trackers - they're cleaned up at the end of the + # WSGI dispatching phase in openerp.service.wsgi_server.application + if self.session._db: + threading.current_thread().dbname = self.session._db + if self.session._uid: + threading.current_thread().uid = self.session._uid + self.context = self.params.pop('context', {}) self.debug = self.params.pop('debug', False) is not False # Determine self.lang