[Mpuls-commits] r761 - in wasko/branches/2.0: . waskaweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Jan 19 18:31:28 CET 2010


Author: bh
Date: 2010-01-19 18:31:26 +0100 (Tue, 19 Jan 2010)
New Revision: 761

Modified:
   wasko/branches/2.0/ChangeLog.txt
   wasko/branches/2.0/waskaweb/lib/app_globals.py
Log:
* waskaweb/lib/app_globals.py (Globals.__init__): Better exception
logging.  Slightly better path handling due to configuration
improvements.


Modified: wasko/branches/2.0/ChangeLog.txt
===================================================================
--- wasko/branches/2.0/ChangeLog.txt	2010-01-19 16:36:36 UTC (rev 760)
+++ wasko/branches/2.0/ChangeLog.txt	2010-01-19 17:31:26 UTC (rev 761)
@@ -1,5 +1,11 @@
 2010-01-19  Bernhard Herzog  <bh at intevation.de>
 
+	* waskaweb/lib/app_globals.py (Globals.__init__): Better exception
+	logging.  Slightly better path handling due to configuration
+	improvements.
+
+2010-01-19  Bernhard Herzog  <bh at intevation.de>
+
 	* waskaweb/lib/app_globals.py: Remove unused import
 
 2010-01-19  Bernhard Herzog  <bh at intevation.de>

Modified: wasko/branches/2.0/waskaweb/lib/app_globals.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/app_globals.py	2010-01-19 16:36:36 UTC (rev 760)
+++ wasko/branches/2.0/waskaweb/lib/app_globals.py	2010-01-19 17:31:26 UTC (rev 761)
@@ -32,11 +32,11 @@
 import waskaweb.lib.security    as security
 from waskaweb.model.annotations import AnnotationsProvider 
 from waskaweb.lib.timelog import setupTimeLogging
-from waskaweb.lib.config import MpulsConfig, get_path
+from waskaweb.lib.config import MpulsConfig
 
-
 log = logging.getLogger(__name__)
 
+
 class Globals(object):
     """Globals acts as a container for objects available throughout the
     life of the application
@@ -49,35 +49,34 @@
         """
         # Load mpuls configuration
         config_file = pylons.config.get('mpuls.app.config', 'default.json')
-        if config_file:
-            if not os.path.isabs(config_file):
-                root = pylons.config.get('pylons.paths').get('root')
-                config_file = os.path.join(root, '..', config_file)
+        if not os.path.isabs(config_file):
+            root = pylons.config.get('pylons.paths').get('root')
+            config_file = os.path.join(root, '..', config_file)
 
-
-        log.info("reading configfile: %s" % config_file)
+        log.info("Loading configfile: %s" % config_file)
         self.config_path = os.path.dirname(config_file)
         self.mpuls_config = MpulsConfig(config_file)
+        log.info("Loading OK")
 
-        # Build FormedTree. This tree will work as template for als cases
-        custom_static  = self.mpuls_config.get('paths', 'public')
-        default_static = pylons.config.get('pylons.paths').get('static_files')
-        formed_dir = 'formed'
-        if custom_static:
-            formed_dir = os.path.join(custom_static, formed_dir)
-        formed      = get_path(formed_dir, self.mpuls_config.get('formed', 'treefile'))
-        annonFile   = get_path(formed_dir, self.mpuls_config.get('formed', 'annotations'))
+        public_dir = pylons.config.get('pylons.paths').get('static_files')
+        formed_dir = os.path.join(public_dir, "formed")
+        formed_file = os.path.join(formed_dir,
+                                   self.mpuls_config.get('formed', 'treefile'))
+        annotation_file = os.path.join(formed_dir,
+                                       self.mpuls_config.get('formed',
+                                                             'annotation'))
 
-        self.formedTree = openDocument(formed)
+        # Build FormedTree. This tree will work as template for all cases
+        self.formedTree = openDocument(formed_file)
         try:
-            self.helpData = AnnotationsProvider(annonFile) 
+            self.helpData = AnnotationsProvider(annotation_file)
         except:
-            traceback.print_exc(file=sys.stderr)
-            print >> sys.stderr, "Could not open Helpfile"
-            self.helpData = None
+            # annotations are optional
+            # FIXME: it would be better to distinguish between a missing
+            # file and parse errors.
+            log.exception("Could not open helpfile %r", annotation_file)
 
         # data for database connections
-
         host   = config.get('mpuls.db.host')
         port   = config.get('mpuls.db.port')
         dbname = config.get('mpuls.db.database')



More information about the Mpuls-commits mailing list