[Mpuls-commits] r4570 - in base/trunk: . mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 3 20:17:58 CET 2011


Author: bh
Date: 2011-02-03 20:17:57 +0100 (Thu, 03 Feb 2011)
New Revision: 4570

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/model/case.py
Log:
Implement mpuls/issue1681: trigger tagging after import

* mpulsweb/model/case.py (MPulsXMLImporter.__init__): New instance
variable imported_ids to keep track of the ids of the imported
data sets
(MPulsXMLImporter.import_xml): Trigger retagging of the imported
data sets if the import was successful
(MPulsXMLImporter.import_case): Add the id of the dataset to
imported_ids.
(MPulsXMLImporter): Update doc-string.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2011-02-03 16:37:48 UTC (rev 4569)
+++ base/trunk/ChangeLog	2011-02-03 19:17:57 UTC (rev 4570)
@@ -1,5 +1,18 @@
 2011-02-03  Bernhard Herzog  <bh at intevation.de>
 
+	Implement mpuls/issue1681: trigger tagging after import
+
+	* mpulsweb/model/case.py (MPulsXMLImporter.__init__): New instance
+	variable imported_ids to keep track of the ids of the imported
+	data sets
+	(MPulsXMLImporter.import_xml): Trigger retagging of the imported
+	data sets if the import was successful
+	(MPulsXMLImporter.import_case): Add the id of the dataset to
+	imported_ids.
+	(MPulsXMLImporter): Update doc-string.
+
+2011-02-03  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/model/case.py (MPulsXMLImporter): Update doc-string
 
 2011-02-03  Bernhard Herzog  <bh at intevation.de>

Modified: base/trunk/mpulsweb/model/case.py
===================================================================
--- base/trunk/mpulsweb/model/case.py	2011-02-03 16:37:48 UTC (rev 4569)
+++ base/trunk/mpulsweb/model/case.py	2011-02-03 19:17:57 UTC (rev 4570)
@@ -1369,6 +1369,12 @@
     This class extends the base class with the following functionality:
 
      - Import of logbook entries
+
+     - Triggering validity checks after import.
+
+       To achieve this, the class keeps track of the ids of the imported
+       datasets and only when all datasets have been imported
+       successfully, it triggers the validity checks.
     """
 
     UUID_ANONYMIZED_SQL = """SELECT is_uuid_anonymized(%(uuid)s)"""
@@ -1383,6 +1389,7 @@
             extra_factories = dict()
         extra_factories["tagebuch"] = get_logbook_import_factory()
         DBXMLImporter.__init__(self, meta_tree, extra_factories)
+        self.imported_ids = []
 
     def import_xml(self, db, infile):
         """Extend the base class method to reformat rule violation exceptions
@@ -1395,6 +1402,14 @@
                                                             e.set_data_errors))
             raise
 
+        # Trigger the tagging of the newly imported data sets.
+        #
+        # We should only get here if there were no errors during import.
+        # If there were any errors, an XMLImportException will have been
+        # raised and the DB changes will have been rolled back and no
+        # tagging will be necessary necessary anyway.
+        g.case.check_validity_for_ids(self.imported_ids)
+
     def format_errors(self, uuid, error_items):
         out = []
         out.append(h.escape(_("The case with UUID '%s' could not be"
@@ -1417,6 +1432,7 @@
                 # only try to import logbook if there actually was a
                 # logbook for the case
                 import_logbook(tree, cursor, components["tagebuch"])
+            self.imported_ids.append(tree.getRootNode().getIdentifier())
 
     def import_allowed(self, cursor, components):
         uuid = components["master"].uuid



More information about the Mpuls-commits mailing list