[IMP] web.http: factor out session path generation
bzr revid: rco@openerp.com-20121116150131-a2ioomezc62kqgrb
This commit is contained in:
parent
01b9f4c3ed
commit
f2bc7b8f4d
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue