[Mpuls-commits] r2485 - wasko/branches/2.0/mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Apr 22 15:01:45 CEST 2010


Author: torsten
Date: 2010-04-22 15:01:45 +0200 (Thu, 22 Apr 2010)
New Revision: 2485

Modified:
   wasko/branches/2.0/mpulsweb/model/phase.py
Log:
* mpulsweb/model/phase.py (PhaseList.check_consistence): Collect a
list of error fields while checking the consistence. Added the list in
the error message.


Modified: wasko/branches/2.0/mpulsweb/model/phase.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/phase.py	2010-04-22 12:59:17 UTC (rev 2484)
+++ wasko/branches/2.0/mpulsweb/model/phase.py	2010-04-22 13:01:45 UTC (rev 2485)
@@ -22,7 +22,7 @@
 log = logging.getLogger(__name__)
 
 CASE_NOT_CONSISTENT = """Die Phase '%s' ist nicht in einem konsistenten Zustand und
-hat nicht ausgefuellte Pflichtfelder"""
+hat nicht ausgefuellte Pflichtfelder: %s"""
 
 def walk_it(node, type=None):
     items = []
@@ -176,13 +176,23 @@
             
             if p1.id <= current_phase and p1.id in path:
                 if not p1.is_ok(fields, check_setting_phase=False):
+                    errors = []
+                    errors.append('<ol>')
+                    for e in p1.errors:
+                        errors.append('<li>%s</li>' % e)
+                    errors.append('</ol>')
                     raise ConsistenceCheckException(CASE_NOT_CONSISTENT
-                                                    % phases.description)
+                                                    % (phases.description, "".join(errors)))
             
             if p2.id <= current_phase and p2.id in path:
                 if not p2.is_ok(fields, check_setting_phase=False):
+                    errors = []
+                    errors.append('<ol>')
+                    for e in p2.errors:
+                        errors.append('<li>%s</li>' % e)
+                    errors.append('</ol>')
                     raise ConsistenceCheckException(CASE_NOT_CONSISTENT
-                                                    % phases.description)
+                                                    % (phases.description, "".join(errors)))
 
 class Phase:
 
@@ -222,6 +232,7 @@
         self.suc = suc
         self.pre = pre
         self.fields = []
+        self.errors = []
 
         # If id is 0 (which should be the start phasepart of the first phase,
         # add "unknown" phase as predesessor) 
@@ -291,6 +302,7 @@
         # 1. Simulate switching the phase
         # Setting values will trigger evaluation error rules. This way we can
         # check logic rules which are modeled as errors.
+        errors = []
         if check_setting_phase and self.it:
             case_id = self.it.getRootNode().getIdentifier()
             realid = "%s:%s" % (PHASEFIELD, case_id)
@@ -303,17 +315,17 @@
 
         # 2. Check rules
         for field in self.fields:
-            if not fields:
+            if fields is None:
                 # No fields provided -> checkall
                 if not field.is_ok():
-                    return False
+                    errors.append(field.label)
             elif field.name in fields:
                 if not field.is_ok():
-                    return False
+                    errors.append(field.label)
+        self.errors = errors
+        return len(errors) == 0
 
-        return True
 
-
 class StartPhasePart(PhasePart):
     pass
 



More information about the Mpuls-commits mailing list