From 413d527a3e68d7e807637b73a191441addf62fbf Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Thu, 14 May 2015 22:41:58 +0000 Subject: [PATCH] Make settings.ini path configurable via env variable --- app.wsgi | 6 +++++- rophako/settings.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app.wsgi b/app.wsgi index e646011..ea88af5 100644 --- a/app.wsgi +++ b/app.wsgi @@ -12,6 +12,10 @@ sys.path.append(".") activate_this = os.environ['HOME']+'/.virtualenv/rophako/bin/activate_this.py' execfile(activate_this, dict(__file__=activate_this)) -from rophako.app import app as application +def application(environ, start_response): + if "ROPHAKO_SETTINGS" in environ: + os.environ["ROPHAKO_SETTINGS"] = environ["ROPHAKO_SETTINGS"] + from rophako.app import app as _application + return _application(environ, start_response) # vim:ft=python diff --git a/rophako/settings.py b/rophako/settings.py index e1fef71..1c3b2a5 100644 --- a/rophako/settings.py +++ b/rophako/settings.py @@ -27,7 +27,8 @@ class ConfigHandler(object): self.settings.set("DEFAULT", "_year", str(datetime.datetime.now().strftime("%Y"))) # Read the defaults and then apply the custom settings on top. - self.settings.read(["defaults.ini", "settings.ini"]) + settings_file = os.environ.get("ROPHAKO_SETTINGS", "settings.ini") + self.settings.read(["defaults.ini", settings_file]) def print_settings(self): """Pretty-print the contents of the configuration as JSON."""