[cwconfig] Get rid of _forced_mode global 3.26
authorDenis Laxalde <denis.laxalde@logilab.fr>
Thu, 15 Feb 2018 09:35:48 +0100
branch3.26
changeset 12266 043db1f91922
parent 12265 3f57a23e9954
child 12267 4ec56c0bcc5c
[cwconfig] Get rid of _forced_mode global And compute CubicWebNoAppConfiguration.mode within the class namespace. Related to #17132990.
cubicweb/cwconfig.py
--- a/cubicweb/cwconfig.py	Thu Feb 15 09:27:15 2018 +0100
+++ b/cubicweb/cwconfig.py	Thu Feb 15 09:35:48 2018 +0100
@@ -391,8 +391,6 @@
     'float' : 'Float',
     }
 
-_forced_mode = os.environ.get('CW_MODE')
-assert _forced_mode in (None, 'system', 'user')
 
 try:
     _INSTALL_PREFIX = os.environ['CW_INSTALL_PREFIX']
@@ -415,11 +413,12 @@
     quick_start = False
 
     if 'VIRTUAL_ENV' in os.environ:
-        mode = _forced_mode or 'user'
+        mode = os.environ.get('CW_MODE', 'user')
         _CUBES_DIR = join(_INSTALL_PREFIX, 'share', 'cubicweb', 'cubes')
     else:
-        mode = _forced_mode or 'system'
+        mode = os.environ.get('CW_MODE', 'system')
         _CUBES_DIR = join(_INSTALL_PREFIX, 'share', 'cubicweb', 'cubes')
+    assert mode in ('system', 'user'), '"CW_MODE" should be either "user" or "system"'
 
     CUBES_DIR = realpath(abspath(os.environ.get('CW_CUBES_DIR', _CUBES_DIR)))
     CUBES_PATH = os.environ.get('CW_CUBES_PATH', '').split(os.pathsep)