summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLV-426 <lv-426@taproot.org.il>2015-04-28 03:14:33 +0300
committerLV-426 <lv-426@taproot.org.il>2015-04-28 16:46:46 +0300
commit96a00dd68f6538224723abb27edc0265f7570143 (patch)
tree9fd0fbeeaade04d82c1d6fbfaed573a2569bd9fc
parente7d7aaffaa5c3679af778fb1bd0f315f012d6ca8 (diff)
rz_config: generate_default)
-rw-r--r--src/server/rz_server.py22
1 files changed, 14 insertions, 8 deletions
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):