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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Mar 17 11:52:05 CET 2009


Author: teichmann
Date: 2009-03-17 11:52:03 +0100 (Tue, 17 Mar 2009)
New Revision: 377

Modified:
   wasko/trunk/ChangeLog.txt
   wasko/trunk/waskaweb/model/casedocument.py
   wasko/trunk/waskaweb/model/datapage.py
Log:
Do type conversion on save data at casedocument.


Modified: wasko/trunk/ChangeLog.txt
===================================================================
--- wasko/trunk/ChangeLog.txt	2009-03-17 09:58:35 UTC (rev 376)
+++ wasko/trunk/ChangeLog.txt	2009-03-17 10:52:03 UTC (rev 377)
@@ -1,3 +1,10 @@
+2009-03-17	Sascha L. Teichmann	<teichmann at intevation.de>
+
+	* waskaweb/model/datapage.py: Used cached rules from casedocument.
+
+	* waskaweb/model/casedocument.py: Do type conversion. TODO: simulate to
+	  apply the converted data and write the if simulation has succeed.
+	  
 2009-03-17	Torsten Irlaender  <torsten.irlaender at intevation.de> 
 
 	Checkin Snapshot of "Wiederaufnahme", "Neuaufnahme"
@@ -12,7 +19,7 @@
 	  formed/formedtree_web.xml: Snapshot of the current state of
 	  "wiederaufnahme" implementation.
 
-2009-03-16	Sascha L. Teichmann	<teichmann at intevation.de>
+2009-03-17	Sascha L. Teichmann	<teichmann at intevation.de>
 
 	* waskaweb/model/casedocument.py: Added a setData() method. Not
 	  functional yet.

Modified: wasko/trunk/waskaweb/model/casedocument.py
===================================================================
--- wasko/trunk/waskaweb/model/casedocument.py	2009-03-17 09:58:35 UTC (rev 376)
+++ wasko/trunk/waskaweb/model/casedocument.py	2009-03-17 10:52:03 UTC (rev 377)
@@ -33,6 +33,8 @@
 from waskaweb.model.data           import PageNode, WidgetCollector, RuleLeaf
 from waskaweb.model.datapage       import PageStore, EmptyPageStore
 
+from waskaweb.model.semantic       import checkAndConvert, SematicError
+
 from pylons          import session
 from paste.registry  import StackedObjectProxy
 
@@ -70,7 +72,13 @@
             self.pages[name] = page
             return page
 
+class DataSaveException(Exception):
 
+    def __init__(self, desc, errors = None):
+        Exception.__init__(self, desc)
+        self.errors = errors
+
+
 class CaseDocument(Document):
 
     def __init__(self, root=None):
@@ -326,4 +334,32 @@
 
             param_page[k] = v
 
+        # for all affected pages
+
+        # first step: try to convert the incoming data
+
+        not_converted = []
+        for page_name, params in param_pages.items():
+            print >> sys.stderr, "%s: %s" % (page_name, repr(params))
+
+            converted, delete_vars = {}, []
+            for k, v in params.iteritems():
+                if v == "": # no value -> delete it
+                    delete_vars.append(k)
+                else:
+                    widget = self.widgets[k]
+                    try:
+                        converted[k] = checkAndConvert(widget, v)
+                    except SematicError, inst:
+                        not_converted.append((key, value))
+
+            param_pages[page_name] = (converted, delete_vars)
+
+        if not_converted:
+            raise DataSaveException(
+                "Konnte Daten nicht konvertieren", not_converted)
+
+        # second step simulate to apply the data
+
+
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

Modified: wasko/trunk/waskaweb/model/datapage.py
===================================================================
--- wasko/trunk/waskaweb/model/datapage.py	2009-03-17 09:58:35 UTC (rev 376)
+++ wasko/trunk/waskaweb/model/datapage.py	2009-03-17 10:52:03 UTC (rev 377)
@@ -221,7 +221,7 @@
 
         # find all rules that depend on variables to be set.
         # build up a lookup var-name -> list of rules
-        for r in document.findAllByClass(RuleLeaf):
+        for r in document.all_rules:
             mark = r.getMark()
             # warning rules are evaluated at page rendering
             if mark and mark.find("warning:") >= 0 or mark.find("notice:") >= 0:



More information about the Mpuls-commits mailing list