[Mpuls-commits] r758 - in wasko/branches/2.0: . waskaweb/config

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Jan 19 17:25:01 CET 2010


Author: bh
Date: 2010-01-19 17:25:00 +0100 (Tue, 19 Jan 2010)
New Revision: 758

Modified:
   wasko/branches/2.0/ChangeLog.txt
   wasko/branches/2.0/development.ini
   wasko/branches/2.0/waskaweb/config/environment.py
Log:
* environment.py (load_environment): Initialize application with
the correct paths immediately instead of overriding them after
initialization

* development.ini: Add new settings:
mpuls.app.path.public
mpuls.app.path.i18n
mpuls.app.path.addons
mpuls.app.path.templates


Modified: wasko/branches/2.0/ChangeLog.txt
===================================================================
--- wasko/branches/2.0/ChangeLog.txt	2010-01-19 16:15:57 UTC (rev 757)
+++ wasko/branches/2.0/ChangeLog.txt	2010-01-19 16:25:00 UTC (rev 758)
@@ -1,5 +1,17 @@
 2010-01-19  Bernhard Herzog  <bh at intevation.de>
 
+	* environment.py (load_environment): Initialize application with
+	the correct paths immediately instead of overriding them after
+	initialization
+
+	* development.ini: Add new settings:
+	mpuls.app.path.public
+	mpuls.app.path.i18n
+	mpuls.app.path.addons
+	mpuls.app.path.templates
+
+2010-01-19  Bernhard Herzog  <bh at intevation.de>
+
 	* environment.py (load_environment): remove tmpl_options because
 	it's not used
 

Modified: wasko/branches/2.0/development.ini
===================================================================
--- wasko/branches/2.0/development.ini	2010-01-19 16:15:57 UTC (rev 757)
+++ wasko/branches/2.0/development.ini	2010-01-19 16:25:00 UTC (rev 758)
@@ -20,6 +20,12 @@
 # You can provide a user specific configuration for the mpuls server.
 mpuls.app.config=%(here)s/default.json
 
+# installation specific search paths
+mpuls.app.path.public = 
+mpuls.app.path.i18n = 
+mpuls.app.path.addons = 
+mpuls.app.path.templates = 
+
 # for connections to PostgeSQL database
 # db_database: %s will be replaced by certificate value
 # db_user:     first %s -> database name, second %s -> user

Modified: wasko/branches/2.0/waskaweb/config/environment.py
===================================================================
--- wasko/branches/2.0/waskaweb/config/environment.py	2010-01-19 16:15:57 UTC (rev 757)
+++ wasko/branches/2.0/waskaweb/config/environment.py	2010-01-19 16:25:00 UTC (rev 758)
@@ -40,10 +40,25 @@
     """
     # 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')
+    if custom_templates:
+        log.info('Custom "template" directory: %s' % custom_templates)
+        template_urls.append(custom_templates)
+    template_urls.append(os.path.join(root, 'templates'))
+
+    # Static content (images, styles, formed...) 
+    static_url = os.path.join(root, 'public')
+    if global_conf.get('mpuls.app.path.public'):
+        static_url = global_conf.get('mpuls.app.path.public') 
+        log.info('Custom "public" directory: %s' % static_url)
+    
     paths = dict(root=root,
                  controllers=os.path.join(root, 'controllers'),
-                 static_files=os.path.join(root, 'public'),
-                 templates=[os.path.join(root, 'templates')])
+                 static_files=static_url,
+                 templates=template_urls)
 
     # Initialize config with the basic options
     config.init_app(global_conf, app_conf, package='waskaweb',
@@ -53,17 +68,6 @@
     config['pylons.g'] = app_globals.Globals()
     config['pylons.h'] = waskaweb.lib.helpers
 
-    template_urls = []
-    # Check for custom template location and add dir if locatio is defined.
-    custom_templates = config['pylons.g'].mpuls_config.get('paths', 'templates')
-    if custom_templates:
-        template_urls.append(custom_templates)
-    # Check for enabled addons and add template dirs if addon is enabled
-    #template_urls.extend(config['pylons.g'].mpuls_config.get_addons_templates())
-    #template_urls.append(os.path.join(root, 'templates'))
-    config['pylons.paths']['templates'] = template_urls
-    paths['templates'] = template_urls
-
     # Create the Mako TemplateLookup, with the default auto-escaping
     config['pylons.g'].mako_lookup = TemplateLookup(
         directories=paths['templates'],
@@ -74,13 +78,3 @@
 
     # CONFIGURATION OPTIONS HERE (note: all config options will override
     # any Pylons config options)
-
-    # If the user configures a different location of images styles and such
-    # things, overwrite the default public location
-    public_path = config['pylons.g'].mpuls_config.get('paths', 'public')
-    if public_path:
-        print 'Starting with custom configuration for "public" directory: %s' % public_path
-        log.info('Starting with custom configuration for "public" directory: %s' % public_path)
-        config['pylons.paths']['static_files'] = public_path
-
-    print config['pylons.paths']['static_files'] 



More information about the Mpuls-commits mailing list