From 45fd4f2a53bd0564dbcfc463eafe43c482c751a1 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 29 Sep 2015 22:50:02 +0530 Subject: [PATCH] Cleanup casting from values in cfg --- plinth/__main__.py | 2 +- plinth/cfg.py | 4 +++- plinth/tests/test_cfg.py | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plinth/__main__.py b/plinth/__main__.py index 3c009f5c9..3df4040e6 100644 --- a/plinth/__main__.py +++ b/plinth/__main__.py @@ -244,7 +244,7 @@ def configure_django(): STATIC_URL='/'.join([cfg.server_dir, 'static/']).replace('//', '/'), STRONGHOLD_PUBLIC_NAMED_URLS=('users:login', 'users:logout'), TEMPLATE_CONTEXT_PROCESSORS=context_processors, - USE_X_FORWARDED_HOST=bool(cfg.use_x_forwarded_host)) + USE_X_FORWARDED_HOST=cfg.use_x_forwarded_host) django.setup() logger.info('Configured Django with applications - %s', applications) diff --git a/plinth/cfg.py b/plinth/cfg.py index af721ca95..6f0b9fd42 100644 --- a/plinth/cfg.py +++ b/plinth/cfg.py @@ -96,6 +96,8 @@ def read(): else: if datatype == 'int': value = int(value) + if datatype == 'bool': - value = value.lower() == 'true' + value = (value.lower() == 'true') + globals()[name] = value diff --git a/plinth/tests/test_cfg.py b/plinth/tests/test_cfg.py index 869661453..1b5557066 100644 --- a/plinth/tests/test_cfg.py +++ b/plinth/tests/test_cfg.py @@ -222,6 +222,7 @@ class CfgTestCase(unittest.TestCase): self.assertEqual(int(parser.get('Network', 'port')), cfg.port) self.assertEqual(parser.get('Network', 'secure_proxy_ssl_header'), cfg.secure_proxy_ssl_header) + self.assertIsInstance(cfg.use_x_forwarded_host, bool) self.assertEqual(parser.get('Network', 'use_x_forwarded_host'), str(cfg.use_x_forwarded_host)) self.assertEqual(parser.get('Misc', 'danube_edition'),