[Mpuls-commits] r2730 - in base/trunk: . mpulsweb/config

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri May 21 19:49:28 CEST 2010


Author: bh
Date: 2010-05-21 19:49:26 +0200 (Fri, 21 May 2010)
New Revision: 2730

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/config/environment.py
Log:
* mpulsweb/config/environment.py (load_environment): Lookup
settings in both app_conf and global_conf, instead of only in
global_conf.  This allows the settings to be in the application's
section in the configuration file, not only in the DEFAULT
section.  This is necessary when running two MPuls applications in
the same server.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-05-21 17:22:28 UTC (rev 2729)
+++ base/trunk/ChangeLog	2010-05-21 17:49:26 UTC (rev 2730)
@@ -1,5 +1,14 @@
 2010-05-21  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/config/environment.py (load_environment): Lookup
+	settings in both app_conf and global_conf, instead of only in
+	global_conf.  This allows the settings to be in the application's
+	section in the configuration file, not only in the DEFAULT
+	section.  This is necessary when running two MPuls applications in
+	the same server.
+
+2010-05-21  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/lib/base.py (BaseController.__before__): redirect_to
 	will also call url_for so it's actually wrong to pass the return
 	value of url_for to redirect_to because it will be processed

Modified: base/trunk/mpulsweb/config/environment.py
===================================================================
--- base/trunk/mpulsweb/config/environment.py	2010-05-21 17:22:28 UTC (rev 2729)
+++ base/trunk/mpulsweb/config/environment.py	2010-05-21 17:49:26 UTC (rev 2730)
@@ -42,12 +42,20 @@
 
 def load_environment(global_conf, app_conf):
     """Configure the Pylons environment via the ``pylons.config`` object"""
+    def get(item):
+        """Lookup item in app_conf and global_conf.  Return the first one found.
+        If item is found in neither, None is returned.
+        """
+        if item in app_conf:
+            return app_conf[item]
+        return global_conf.get(item)
+
     # Pylons paths
     root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 
     # Templates
     template_urls = []
-    custom_templates = global_conf.get('mpuls.app.path.templates')
+    custom_templates = get('mpuls.app.path.templates')
     if custom_templates:
         log.info('Custom "template" directory: %s' % custom_templates)
         template_urls.append(custom_templates)
@@ -55,16 +63,16 @@
 
     # Static content (images, styles, formed...)
     static_urls = []
-    custom_static = global_conf.get('mpuls.app.path.public')
+    custom_static = get('mpuls.app.path.public')
     if custom_static:
         log.info('Custom "public" directory: %s' % custom_static)
-        static_urls.append(global_conf.get('mpuls.app.path.public'))
+        static_urls.append(get('mpuls.app.path.public'))
     static_urls.append(os.path.join(root, 'public'))
 
     # Controllers
     controller_url = os.path.join(root, 'controllers')
-    if global_conf.get('mpuls.app.path.controllers'):
-        controller_url = global_conf.get('mpuls.app.path.controllers')
+    if get('mpuls.app.path.controllers'):
+        controller_url = get('mpuls.app.path.controllers')
         log.info('Custom "controller" directory: %s' % controller_url)
 
     paths = dict(root=root,



More information about the Mpuls-commits mailing list