[Mpuls-commits] r2855 - in base/trunk: . mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Jun 2 15:45:21 CEST 2010
Author: bh
Date: 2010-06-02 15:45:19 +0200 (Wed, 02 Jun 2010)
New Revision: 2855
Modified:
base/trunk/ChangeLog
base/trunk/mpulsweb/lib/app_globals.py
Log:
* mpulsweb/lib/app_globals.py (Globals.__init__): Refactor common
code to determine filenames from the configuration into a helper
function.
Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog 2010-06-02 13:43:02 UTC (rev 2854)
+++ base/trunk/ChangeLog 2010-06-02 13:45:19 UTC (rev 2855)
@@ -1,3 +1,9 @@
+2010-06-02 Bernhard Herzog <bh at intevation.de>
+
+ * mpulsweb/lib/app_globals.py (Globals.__init__): Refactor common
+ code to determine filenames from the configuration into a helper
+ function.
+
2010-06-01 Bernhard Herzog <bh at intevation.de>
* mpulsweb/lib/validators.py (ValidatorStateObject.__setattr__)
Modified: base/trunk/mpulsweb/lib/app_globals.py
===================================================================
--- base/trunk/mpulsweb/lib/app_globals.py 2010-06-02 13:43:02 UTC (rev 2854)
+++ base/trunk/mpulsweb/lib/app_globals.py 2010-06-02 13:45:19 UTC (rev 2855)
@@ -55,19 +55,17 @@
initialization and is available during requests via the 'g'
variable
"""
+ def filename_from_config(setting, default):
+ return os.path.join(config.get('pylons.paths').get('root'),
+ '..', config.get(setting, default))
+
# Load mpuls configuration
- config_file = config.get('mpuls.app.config', 'default_config.json')
- mapping_file = config.get('mpuls.app.dbmapping', 'default_dbmapping.json')
- tagging_file = config.get('mpuls.app.tagging', 'default_tagging.xml')
- if not os.path.isabs(config_file):
- root = config.get('pylons.paths').get('root')
- config_file = os.path.join(root, '..', config_file)
- if not os.path.isabs(mapping_file):
- root = config.get('pylons.paths').get('root')
- mapping_file = os.path.join(root, '..', mapping_file)
- if not os.path.isabs(tagging_file):
- root = config.get('pylons.paths').get('root')
- tagging_file = os.path.join(root, '..', tagging_file)
+ config_file = filename_from_config('mpuls.app.config',
+ 'default_config.json')
+ mapping_file = filename_from_config('mpuls.app.dbmapping',
+ 'default_dbmapping.json')
+ tagging_file = filename_from_config('mpuls.app.tagging',
+ 'default_tagging.xml')
self.config_path = os.path.dirname(config_file)
self.mpuls_config = MpulsAppConfig(config_file)
More information about the Mpuls-commits
mailing list