[FIX] http: store sessions in data-dir

bzr revid: chs@openerp.com-20140116164142-ikcw82lyfopoj46k
This commit is contained in:
Christophe Simonis 2014-01-16 17:41:42 +01:00
parent a73c02075a
commit db10e1d3a5
2 changed files with 2 additions and 23 deletions

View File

@ -830,33 +830,12 @@ class DisableCacheMiddleware(object):
start_response(status, new_headers) start_response(status, new_headers)
return self.app(environ, start_wrapped) return self.app(environ, start_wrapped)
def session_path():
try:
import pwd
username = pwd.getpwuid(os.geteuid()).pw_name
except ImportError:
try:
username = getpass.getuser()
except Exception:
username = "unknown"
path = os.path.join(tempfile.gettempdir(), "oe-sessions-" + username)
try:
os.mkdir(path, 0700)
except OSError as exc:
if exc.errno == errno.EEXIST:
# directory exists: ensure it has the correct permissions
# this will fail if the directory is not owned by the current user
os.chmod(path, 0700)
else:
raise
return path
class Root(object): class Root(object):
"""Root WSGI application for the OpenERP Web Client. """Root WSGI application for the OpenERP Web Client.
""" """
def __init__(self): def __init__(self):
# Setup http sessions # Setup http sessions
path = session_path() path = os.path.join(openerp.tools.config.session_dir
_logger.debug('HTTP sessions stored in: %s', path) _logger.debug('HTTP sessions stored in: %s', path)
self.session_store = werkzeug.contrib.sessions.FilesystemSessionStore(path, session_class=OpenERPSession) self.session_store = werkzeug.contrib.sessions.FilesystemSessionStore(path, session_class=OpenERPSession)

View File

@ -633,7 +633,7 @@ class configmanager(object):
@property @property
def session_dir(self): def session_dir(self):
d = os.path.join(self['data_dir'], 'sessions') d = os.path.join(self['data_dir'], 'sessions', release.series)
if not os.path.exists(d): if not os.path.exists(d):
os.makedirs(d) os.makedirs(d)
return d return d