Cleanup casting from values in cfg

This commit is contained in:
Sunil Mohan Adapa 2015-09-29 22:50:02 +05:30
parent b63ec9bffc
commit 45fd4f2a53
3 changed files with 5 additions and 2 deletions

View File

@ -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)

View File

@ -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

View File

@ -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'),