From 96a00dd68f6538224723abb27edc0265f7570143 Mon Sep 17 00:00:00 2001 From: LV-426 Date: Tue, 28 Apr 2015 03:14:33 +0300 Subject: rz_config: generate_default) --- src/server/rz_server.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/server') diff --git a/src/server/rz_server.py b/src/server/rz_server.py index c817e0f1..cb36a617 100644 --- a/src/server/rz_server.py +++ b/src/server/rz_server.py @@ -42,21 +42,16 @@ class Config(object): """ @staticmethod - def init_from_file(file_path): - - if False == os.path.exists(file_path): - raise Exception('config file not found: ' + file_path) - - # apply defaults + def generate_default(): cfg = {} - cfg['config_dir'] = os.path.abspath(os.path.dirname(file_path)) # bypass prop restriction + cfg['config_dir'] = '.' cfg['development_mode'] = False cfg['listen_address'] = '127.0.0.1' cfg['listen_port'] = 8080 cfg['log_level'] = 'INFO' cfg['root_path'] = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) cfg['static_url_path'] = '/static' - cfg['user_db_path'] = os.path.join(cfg['config_dir'], 'user_db.db') + cfg['user_db_path'] = './user_db.db' # client configuration cfg['optimized_main'] = False @@ -88,6 +83,17 @@ class Config(object): cfg['rzdoc__mainpage_name'] = 'Welcome Rhizi' cfg['rzdoc__name__max_length'] = 256 + return cfg + + @staticmethod + def init_from_file(file_path): + + if False == os.path.exists(file_path): + raise Exception('config file not found: ' + file_path) + + cfg = Config.generate_default() + cfg['config_dir'] = os.path.abspath(os.path.dirname(file_path)) # bypass prop restriction + with open(file_path, 'r') as f: for line in f: if re.match('(^#)|(\s+$)', line): -- cgit v1.3.1