[Mpuls-commits] r5738 - base/trunk/mpulsweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Dec 22 15:57:46 CET 2011
Author: torsten
Date: 2011-12-22 15:57:45 +0100 (Thu, 22 Dec 2011)
New Revision: 5738
Modified:
base/trunk/mpulsweb/model/case.py
Log:
Make code more stable to load a case even if not fields are configured for the
case. If so add at least the field "id" to the query to not build a broen sql
query and continue loading a case.
Modified: base/trunk/mpulsweb/model/case.py
===================================================================
--- base/trunk/mpulsweb/model/case.py 2011-12-22 14:46:30 UTC (rev 5737)
+++ base/trunk/mpulsweb/model/case.py 2011-12-22 14:57:45 UTC (rev 5738)
@@ -822,6 +822,7 @@
"""
phaseslist = self.get_phaseslist()
curphase = phaseslist.get_current_phase_id()
+ self._load_formed_instance_tree()
data = {}
for phase in phaseslist:
@@ -851,7 +852,7 @@
for field in start.fields:
if data.has_key("%s" % (field.id)):
continue
- item = self.get_formed_item(field.name)
+ item = self.formed_instance.getItem(field.id)
try:
value = item.getValue()
log.debug('Current value of %s: %s' % (field.id, value))
@@ -868,7 +869,7 @@
if data.has_key("%s" % (field.id)):
continue
try:
- item = self.get_formed_item(field.name)
+ item = self.formed_instance.getItem(field.id)
value = item.getValue()
log.debug('Current value of %s: %s' % (field.id, value))
if item.getValue() in [-1, "-1", None, ""]:
@@ -1252,6 +1253,10 @@
conn = db.getConnection()
c = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
fields = self.case_cls.get_preload_fields()
+ # Ensure that at least one field (id) is loaded if no fields are
+ # configured for the case in JSON config.
+ if "id" not in fields:
+ fields.append('id')
query = LOAD_CASE_SQL % dict(fields=", ".join(fields))
fields = {'id': id}
log.debug("Query: %s", query)
More information about the Mpuls-commits
mailing list