[Mpuls-commits] r327 - in wasko/trunk: . waskaweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Mar 4 14:36:01 CET 2009


Author: teichmann
Date: 2009-03-04 14:36:00 +0100 (Wed, 04 Mar 2009)
New Revision: 327

Modified:
   wasko/trunk/ChangeLog.txt
   wasko/trunk/waskaweb/model/casexml.py
Log:
XML Import: raise XMLImportException when expected errors occur.


Modified: wasko/trunk/ChangeLog.txt
===================================================================
--- wasko/trunk/ChangeLog.txt	2009-03-04 13:32:03 UTC (rev 326)
+++ wasko/trunk/ChangeLog.txt	2009-03-04 13:36:00 UTC (rev 327)
@@ -1,3 +1,8 @@
+2009-03-04	Sascha L. Teichmann	<teichmann at intevation.de>
+
+	* waskaweb/model/casexml.py: Raise XMLImportException when an 
+	  expected error occurs.
+
 2009-03-04	Torsten Irlaender  <torsten.irlaender at intevation.de> 
 
 	Store full username in logboook instead of user id

Modified: wasko/trunk/waskaweb/model/casexml.py
===================================================================
--- wasko/trunk/waskaweb/model/casexml.py	2009-03-04 13:32:03 UTC (rev 326)
+++ wasko/trunk/waskaweb/model/casexml.py	2009-03-04 13:36:00 UTC (rev 327)
@@ -101,6 +101,12 @@
     if row: return row[0]
     return None
 
+class XMLImportException(Exception):
+
+    def __init__(self, desc, errors = None):
+        Exception.__init__(self, desc)
+        self.errors = errors
+
 class LogbookEntry(object):
 
     def __init__(self, uuid = None):
@@ -200,7 +206,7 @@
             old = get_logbuch_ids_from_uuid(cur, self.uuid)
             if old:
                 if old[1] != ds_id:
-                    raise StandardError('uuid leads to wrong master id')
+                    raise StandardError(u'UUID gehört zum falschen Datensatz.')
                 lid = old[0]
 
         if lid is None:
@@ -302,7 +308,7 @@
         if self.entry: 
             value = value.strip()
             if not is_uuid(value):
-                raise ValueError("'%s' is not an UUID" % repr(value))
+                raise XMLImportException("'%s' ist keine UUID." % repr(value))
             self.entry.uuid = value
 
     def default_start(self, name, attrs):
@@ -339,7 +345,7 @@
             if name == u'uuid_id':
                 value = value.strip()
                 if not is_uuid(value):
-                    raise ValueError("'%s' is not an UUID" % repr(value))
+                    raise XMLImportException(u"'%s' ist keine UUID" % repr(value))
                 self.uuid = value
             return
 
@@ -400,7 +406,7 @@
                     cur.execute(SQL_SELECT_ALL_FROM_MASTER % { 'ds_id': ds_id })
                     row = cur.fetchone()
                     if not row:
-                        raise StandardError("could not load data for id '%s'" % ds_id)
+                        raise XMLImportException(u"Daten zum Fall '%d' können nicht geladen werden." % ds_id)
                     data = dict(zip([n[0] for n in cur.description], map(convert_from_db, row)))
                     create_case = False
                 #else:
@@ -454,7 +460,8 @@
                     changed[var] = value
 
             if errors:
-                raise StandardError("rule checking failed")
+                raise XMLImportException(
+                    u"Es wurden Inkonsistenzen festgestellt.", errors)
 
             if create_case:
                 ds_id = create_master(cur, master_handler.uuid)



More information about the Mpuls-commits mailing list