[cwconfig] Retrieve real path of cubes directory 3.24
authorDenis Laxalde <denis.laxalde@logilab.fr>
Fri, 09 Dec 2016 15:08:52 +0100
branch3.24
changeset 11881 6707748e3982
parent 11879 c8306ac9df59
child 11882 ccf61228a802
[cwconfig] Retrieve real path of cubes directory Since logilab-common 1.3.0, we have real path expansion modutils.modpath_from_file. But the extrapath parameter that is passed from cubicweb.schema reader may still have symlinks, so expand them here to hopefully have consistent comparison in modpath_from_file.
cubicweb/cwconfig.py
--- a/cubicweb/cwconfig.py	Wed Dec 07 14:13:20 2016 +0100
+++ b/cubicweb/cwconfig.py	Fri Dec 09 15:08:52 2016 +0100
@@ -185,7 +185,7 @@
 import logging
 import logging.config
 import os
-from os.path import (exists, join, expanduser, abspath, normpath,
+from os.path import (exists, join, expanduser, abspath, normpath, realpath,
                      basename, isdir, dirname, splitext)
 import pkgutil
 import pkg_resources
@@ -378,7 +378,7 @@
         mode = _forced_mode or 'system'
         _CUBES_DIR = join(_INSTALL_PREFIX, 'share', 'cubicweb', 'cubes')
 
-    CUBES_DIR = abspath(os.environ.get('CW_CUBES_DIR', _CUBES_DIR))
+    CUBES_DIR = realpath(abspath(os.environ.get('CW_CUBES_DIR', _CUBES_DIR)))
     CUBES_PATH = os.environ.get('CW_CUBES_PATH', '').split(os.pathsep)
 
     options = (
@@ -513,7 +513,7 @@
     @classmethod
     def cubes_search_path(cls):
         """return the path of directories where cubes should be searched"""
-        path = [abspath(normpath(directory)) for directory in cls.CUBES_PATH
+        path = [realpath(abspath(normpath(directory))) for directory in cls.CUBES_PATH
                 if directory.strip() and exists(directory.strip())]
         if not cls.CUBES_DIR in path and exists(cls.CUBES_DIR):
             path.append(cls.CUBES_DIR)