From e96fa64fa6534bda180e1a69ed7f3fd72829c09d Mon Sep 17 00:00:00 2001 From: Unrud Date: Sun, 29 Apr 2018 21:45:34 +0200 Subject: [PATCH] WSGI: Get RADICALE_CONFIG from environ instead of os.environ --- radicale/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 526e3cd..93f069a 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -952,14 +952,16 @@ class Application: _application = None +_application_config_path = None _application_lock = threading.Lock() def _init_application(config_path): - global _application + global _application, _application_config_path with _application_lock: if _application is not None: return + _application_config_path = config_path configuration = config.load([config_path] if config_path else [], ignore_missing_paths=False) filename = os.path.expanduser(configuration.get("logging", "config")) @@ -969,7 +971,10 @@ def _init_application(config_path): def application(environ, start_response): - config_path = os.environ.get("RADICALE_CONFIG") + config_path = environ.get("RADICALE_CONFIG") if _application is None: _init_application(config_path) + if _application_config_path != config_path: + raise ValueError("RADICALE_CONFIG must not change: %s != %s" % + (repr(config_path), repr(_application_config_path))) return _application(environ, start_response)