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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Feb 26 12:11:09 CET 2010


Author: torsten
Date: 2010-02-26 12:11:09 +0100 (Fri, 26 Feb 2010)
New Revision: 1842

Modified:
   wasko/branches/2.0/mpulsweb/model/case.py
Log:
Fixed setting default values


Modified: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py	2010-02-26 11:06:38 UTC (rev 1841)
+++ wasko/branches/2.0/mpulsweb/model/case.py	2010-02-26 11:11:09 UTC (rev 1842)
@@ -31,7 +31,7 @@
 
 import psycopg2.extras
 
-from formed.meta.data import RepeatNode, DateLeaf, IntLeaf, TextLeaf
+from formed.meta.data import RepeatNode, DateLeaf, IntLeaf, TextLeaf, ChoiceNode
 from formed.instance.backends.postgres import DBFactory as InstanceFactory
 from formed.instance.tree import SetDataException
 
@@ -78,8 +78,10 @@
        value  = '-999999'
     elif isinstance(meta, TextLeaf):
        value  = 'unbekannt'
+    elif isinstance(meta, ChoiceNode):
+       value  = '-3'
     else:
-       value  = '-3'
+       value  = None 
     return value
 
 def get_field_identifier(id, name, it=None, idx=0):
@@ -297,7 +299,8 @@
                 if value in [-1, "-1", None, ""]:
                     def_value = get_default_value(item)
                     log.debug("Setting %s to %s" % (field.name, def_value))
-                    data["%s:%s" % (field.name, self.id)] = def_value 
+                    if def_value:
+                        data["%s:%s" % (field.name, self.id)] = def_value 
             for field in end.fields:
                 item = self._get_formed_item(field.name)
                 value = item.getValue()
@@ -305,7 +308,8 @@
                 if item.getValue() in [-1, "-1", None, ""]:
                     def_value = get_default_value(item)
                     log.debug("Setting %s to %s" % (field.name, def_value))
-                    data["%s:%s" % (field.name, self.id)] = def_value 
+                    if def_value:
+                        data["%s:%s" % (field.name, self.id)] = def_value 
 
         # Set values
         self.formed_instance.setData(data)



More information about the Mpuls-commits mailing list