[Mpuls-commits] r6003 - base/trunk/mpulsweb/lib

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Tue Jul 31 12:28:34 CEST 2012


Author: bricks
Date: 2012-07-31 12:28:34 +0200 (Tue, 31 Jul 2012)
New Revision: 6003

Modified:
   base/trunk/mpulsweb/lib/app_globals.py
Log:
Allow overriding of loading the formed tree document

To allow to use generating required rules in mpuls applications it become
necessary to use openDocument with an additional parameter. Therefore allow the
mpuls application to override loading the formed tree and keep the current code
path backwards compatible.


Modified: base/trunk/mpulsweb/lib/app_globals.py
===================================================================
--- base/trunk/mpulsweb/lib/app_globals.py	2012-07-26 13:26:22 UTC (rev 6002)
+++ base/trunk/mpulsweb/lib/app_globals.py	2012-07-31 10:28:34 UTC (rev 6003)
@@ -115,30 +115,14 @@
         self.mpuls_dbmapping = MpulsDBMapping(mapping_file)
         self.mpuls_dblist = MpulsDBList(dblist_file)
 
-        # Load formed from defined location. If no location is defined. Take
-        # the default which is the formed dir under public.
-        formed_dir = config.get('mpuls.app.path.formed',
-            os.path.join(config.get('pylons.paths').get('static_files')[0],
-                         '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._load_form(config)
 
-        # Build FormedTree. This tree will work as template for all cases
-        log.debug("loading formed definition from %r", formed_file)
-        self.formedTree = openDocument(formed_file)
-        self.helpData = AnnotationsProvider(annotation_file)
-
         # Load taggingconfig
         log.debug("Loading configuration for tagging from %s" % tagging_file)
         self.taggingConfFile = tagging_file
         self.taggingConf = TagSetterConfig(tagging_file) 
 
         # tell paste to restart the server if the formed files change
-        watch_file(formed_file)
-        watch_file(annotation_file)
         watch_file(tagging_file)
 
         # meta-server settings
@@ -205,3 +189,25 @@
 
     def _get_config(self, filename):
         return MpulsAppConfig(filename)
+
+    def _load_form(self, config):
+        # Load formed from defined location. If no location is defined. Take
+        # the default which is the formed dir under public.
+        formed_dir = config.get('mpuls.app.path.formed',
+            os.path.join(config.get('pylons.paths').get('static_files')[0],
+                         '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 = self._load_formedtree_from_file(formed_file)
+        self.helpData = AnnotationsProvider(annotation_file)
+
+        watch_file(formed_file)
+        watch_file(annotation_file)
+
+    def _load_formedtree_from_file(self, formed_file):
+        # Build FormedTree. This tree will work as template for all cases
+        log.debug("loading formed definition from %r", formed_file)
+        return openDocument(formed_file)



More information about the Mpuls-commits mailing list