[Mpuls-commits] r379 - in wasko/trunk: . waskaweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Mar 17 12:27:48 CET 2009
Author: teichmann
Date: 2009-03-17 12:27:46 +0100 (Tue, 17 Mar 2009)
New Revision: 379
Modified:
wasko/trunk/ChangeLog.txt
wasko/trunk/waskaweb/model/casedocument.py
Log:
If simulation has succeed write back the changes in case formed document.
Modified: wasko/trunk/ChangeLog.txt
===================================================================
--- wasko/trunk/ChangeLog.txt 2009-03-17 11:18:00 UTC (rev 378)
+++ wasko/trunk/ChangeLog.txt 2009-03-17 11:27:46 UTC (rev 379)
@@ -1,5 +1,9 @@
2009-03-17 Sascha L. Teichmann <teichmann at intevation.de>
+ * waskaweb/model/casedocument.py: Write back the simulation results.
+
+2009-03-17 Sascha L. Teichmann <teichmann at intevation.de>
+
* waskaweb/model/casedocument.py: Do simulation and raise exceptions
if rules are violated. TODO write back changes.
Modified: wasko/trunk/waskaweb/model/casedocument.py
===================================================================
--- wasko/trunk/waskaweb/model/casedocument.py 2009-03-17 11:18:00 UTC (rev 378)
+++ wasko/trunk/waskaweb/model/casedocument.py 2009-03-17 11:27:46 UTC (rev 379)
@@ -329,22 +329,29 @@
param_page[k] = v
- # for all affected pages
+ not_converted = []
# first step: try to convert the incoming data
+ if ds_id is None:
+ case = session.get('case')
+ if not case: return None
+ ds_id = case.id
- not_converted = []
for page_name, params in param_pages.items():
print >> sys.stderr, "%s: %s" % (page_name, repr(params))
+ ps = self.getPageStore(page_name, ds_id)
converted, delete_vars = {}, []
for k, v in params.iteritems():
if v == "": # no value -> delete it
- delete_vars.append(k)
+ if ps.getData(k) != None: # NULL already?
+ delete_vars.append(k)
else:
widget = self.widgets[k]
try:
- converted[k] = checkAndConvert(widget, v)
+ nv = checkAndConvert(widget, v)
+ if nv != ps.getData(k): # only if it's a change
+ converted[k] = nv
except SematicError, inst:
not_converted.append((key, value))
@@ -355,14 +362,8 @@
"Konnte Daten nicht konvertieren", not_converted)
# second step: simulate to apply the data
- if ds_id is None:
- case = session.get('case')
- if not case: return None
- ds_id = case.id
-
- for page_name, params in param_pages.iteritems():
+ for page_name, params in param_pages.items():
params, delete_vars = params
- #ps = self.getPageStore(page_name, ds_id)
simulation = dict([(n, None) for n in delete_vars])
def getValue(n):
@@ -404,10 +405,19 @@
else:
simulation[k] = v
+ # only write back the minimal changeset
+ param_pages[param_pages] = simulation
+
if not_converted:
raise DataSaveException(
"Datenkonsistenz nicht eingehalten", not_converted)
+ # third step: write back the changes:
+ for page_name, params in param_pages.iteritems():
+ if not params: continue
+ ps = self.getPageStore(page_name, ds_id)
+ for k, v in params.iteritems():
+ ps.setData(k, v)
+ ps.store()
-
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
More information about the Mpuls-commits
mailing list