From f2bc7b8f4d047782300bc7c360509b2b29e03e89 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 16 Nov 2012 16:01:31 +0100 Subject: [PATCH] [IMP] web.http: factor out session path generation bzr revid: rco@openerp.com-20121116150131-a2ioomezc62kqgrb --- addons/web/http.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/web/http.py b/addons/web/http.py index 46025ae4c62..fc80cb03864 100644 --- a/addons/web/http.py +++ b/addons/web/http.py @@ -458,6 +458,16 @@ class DisableCacheMiddleware(object): start_response(status, new_headers) return self.app(environ, start_wrapped) +def session_path(): + try: + username = getpass.getuser() + except Exception: + username = "unknown" + path = os.path.join(tempfile.gettempdir(), "oe-sessions-" + username) + if not os.path.exists(path): + os.mkdir(path, 0700) + return path + class Root(object): """Root WSGI application for the OpenERP Web Client. """ @@ -469,13 +479,7 @@ class Root(object): self.dispatch = DisableCacheMiddleware(app) # Setup http sessions - try: - username = getpass.getuser() - except Exception: - username = "unknown" - path = os.path.join(tempfile.gettempdir(), "oe-sessions-" + username) - if not os.path.exists(path): - os.mkdir(path, 0700) + path = session_path() self.session_store = werkzeug.contrib.sessions.FilesystemSessionStore(path) self.session_lock = threading.Lock() _logger.debug('HTTP sessions stored in: %s', path)