[FIX] data-dir management

- sessions are now shared between series.
- use site data dir instead of user data dir if user has no home dir.
- in http and module handling, `data-dir` was used before being
initialized, using the default value instead of user input

(fixes #308, #904)
This commit is contained in:
Christophe Simonis 2014-07-07 15:32:25 +02:00
parent 139d868c94
commit e5b0933743
3 changed files with 15 additions and 5 deletions

View File

@ -1145,11 +1145,14 @@ class Root(object):
"""Root WSGI application for the OpenERP Web Client.
"""
def __init__(self):
self._loaded = False
@lazy_property
def session_store(self):
# Setup http sessions
path = openerp.tools.config.session_dir
_logger.debug('HTTP sessions stored in: %s', path)
self.session_store = werkzeug.contrib.sessions.FilesystemSessionStore(path, session_class=OpenERPSession)
self._loaded = False
return werkzeug.contrib.sessions.FilesystemSessionStore(path, session_class=OpenERPSession)
@lazy_property
def nodb_routing_map(self):

View File

@ -43,7 +43,7 @@ MANIFEST = '__openerp__.py'
_logger = logging.getLogger(__name__)
# addons path as a list
ad_paths = [tools.config.addons_data_dir]
ad_paths = []
hooked = False
# Modules already loaded
@ -89,6 +89,10 @@ def initialize_sys_path():
global ad_paths
global hooked
dd = tools.config.addons_data_dir
if dd not in ad_paths:
ad_paths.append(dd)
for ad in tools.config['addons_path'].split(','):
ad = os.path.abspath(tools.ustr(ad.strip()))
if ad not in ad_paths:

View File

@ -61,7 +61,10 @@ def check_ssl():
DEFAULT_LOG_HANDLER = [':INFO']
def _get_default_datadir():
return appdirs.user_data_dir(appname='OpenERP', appauthor=release.author)
home = os.path.expanduser('~')
func = appdirs.user_data_dir if os.path.exists(home) else appdirs.site_data_dir
# No "version" kwarg as session and filestore paths are shared against series
return func(appname='Odoo', appauthor=release.author)
class configmanager(object):
def __init__(self, fname=None):
@ -649,7 +652,7 @@ class configmanager(object):
@property
def session_dir(self):
d = os.path.join(self['data_dir'], 'sessions', release.series)
d = os.path.join(self['data_dir'], 'sessions')
if not os.path.exists(d):
os.makedirs(d, 0700)
else: