[Mpuls-commits] r5696 - base/trunk/mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Dec 7 11:34:37 CET 2011


Author: bricks
Date: 2011-12-07 11:34:36 +0100 (Wed, 07 Dec 2011)
New Revision: 5696

Modified:
   base/trunk/mpulsweb/controllers/case.py
Log:
Allow to customize the xml importer in a derived case class

For mpuls_S it should be possible to add some custom checks before the 
import to avoid some common import errors.


Modified: base/trunk/mpulsweb/controllers/case.py
===================================================================
--- base/trunk/mpulsweb/controllers/case.py	2011-12-06 13:17:01 UTC (rev 5695)
+++ base/trunk/mpulsweb/controllers/case.py	2011-12-07 10:34:36 UTC (rev 5696)
@@ -589,6 +589,15 @@
         a custom validator'''
         return NewCaseForm()
 
+    def _get_xmlimporter(self):
+        '''This function should be overwritten in specific applications to add
+        a custom XML Importer'''
+        allow_documents = g.mpuls_config.is_enabled('case-module', 'documents')
+        allow_logbook = g.mpuls_config.is_enabled('case-module', 'logbook')
+        return MPulsXMLImporter(g.formedTree,
+                                allow_logbook=allow_logbook,
+                                allow_documents=allow_documents)
+
     def _convert_SetDataException2Formencode(self, err):
         """Convert a SetDataException into a formencode compatible dictionary"""
 
@@ -681,12 +690,7 @@
     @checkRole('cm')
     def importXMLAction(self):
         try:
-            allow_documents = g.mpuls_config.is_enabled('case-module',
-                                                        'documents')
-            allow_logbook = g.mpuls_config.is_enabled('case-module', 'logbook')
-            importer = MPulsXMLImporter(g.formedTree,
-                                        allow_logbook=allow_logbook,
-                                        allow_documents=allow_documents)
+            importer = self._get_xmlimporter()
 
             xmlfile = request.POST['xmlfile']
             try:



More information about the Mpuls-commits mailing list