From e18a974c218cb73859c903e0558360b7f3dd985d Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Fri, 14 Feb 2014 09:59:05 +0530 Subject: [PATCH] sites wide site_config --- webnotes/__init__.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/webnotes/__init__.py b/webnotes/__init__.py index 698a565a4a..b18ba60829 100644 --- a/webnotes/__init__.py +++ b/webnotes/__init__.py @@ -118,12 +118,14 @@ def init(site, sites_path=None): setup_module_map() def get_site_config(): - site_filepath = os.path.join(local.site_path, "site_config.json") - if os.path.exists(site_filepath): - with open(site_filepath, 'r') as f: - return json.load(f) - else: - return _dict() + config = {} + sites_config_filepath = os.path.join(local.sites_path, "site_config.json") + site_config_filepath = os.path.join(local.site_path, "site_config.json") + if os.path.exists(sites_config_filepath): + config = get_file_json(sites_config_filepath) + if os.path.exists(site_config_filepath): + config.update(get_file_json(site_config_filepath)) + return _dict(config) def destroy(): """closes connection and releases werkzeug local""" @@ -456,6 +458,10 @@ def get_file_items(path): else: return [] +def get_file_json(path): + with open(path, 'r') as f: + return json.load(f) + def read_file(path): if os.path.exists(path): with open(path, "r") as f: