[Mpuls-commits] r3909 - in base/trunk: . mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Oct 6 16:04:33 CEST 2010


Author: bh
Date: 2010-10-06 16:04:32 +0200 (Wed, 06 Oct 2010)
New Revision: 3909

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/controllers/formularpage.py
Log:
* mpulsweb/controllers/formularpage.py
(FormularpageController.save): rearrange the code so that only the
instance_tree.setData call is in the try-except statement that
catches the SetDataException.  This way all the other code in the
try block after the setData call is still executed even if the
setData call raises the SetDataException.  In particular, the code
that handles the repeat group actions is still run so that
creating and deleting inline repeat groups while there are
uncomitted chagnes works again.
Fixes mpuls/issue807


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-10-06 14:00:16 UTC (rev 3908)
+++ base/trunk/ChangeLog	2010-10-06 14:04:32 UTC (rev 3909)
@@ -1,5 +1,18 @@
 2010-10-06  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/controllers/formularpage.py
+	(FormularpageController.save): rearrange the code so that only the
+	instance_tree.setData call is in the try-except statement that
+	catches the SetDataException.  This way all the other code in the
+	try block after the setData call is still executed even if the
+	setData call raises the SetDataException.  In particular, the code
+	that handles the repeat group actions is still run so that
+	creating and deleting inline repeat groups while there are
+	uncomitted chagnes works again.
+	Fixes mpuls/issue807
+
+2010-10-06  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/controllers/formularpage.py: Remove unused imports.
 
 2010-10-06  Torsten Irlaender <torsten at intevation.de>

Modified: base/trunk/mpulsweb/controllers/formularpage.py
===================================================================
--- base/trunk/mpulsweb/controllers/formularpage.py	2010-10-06 14:00:16 UTC (rev 3908)
+++ base/trunk/mpulsweb/controllers/formularpage.py	2010-10-06 14:04:32 UTC (rev 3909)
@@ -193,33 +193,31 @@
             case_id,
             session.get('uncommited_fields'))
         page_id = request.params['page']
-        try:
-            form_result = convert2dic(request.params)
-            apply_hidden_booleans(form_result)
 
-            self._before_set_data_hook(case_id, form_result)
+        form_result = convert2dic(request.params)
+        apply_hidden_booleans(form_result)
 
+        self._before_set_data_hook(case_id, form_result)
+
+        try:
             instance_tree.setData(form_result)
-            session['uncommited_fields'] = instance_tree.commit()
-            session.save()
+        except SetDataException, err:
+            # We can ignore this exception because errors that occurred
+            # will be shown to the user on the form page anyway via the
+            # uncommitted fields data stored in the session.
+            pass
+        session['uncommited_fields'] = instance_tree.commit()
+        session.save()
 
-            # How to proceed after saving the data?
-            self._handle_repeat_group_redirects()
+        # How to proceed after saving the data?
+        self._handle_repeat_group_redirects()
 
-            if request.params.has_key('savenext'):
-                page_id = session['navigation.tree'].getTreeItem(page_id).nextKey().key
+        if request.params.has_key('savenext'):
+            page_id = session['navigation.tree'].getTreeItem(page_id).nextKey().key
 
-            # Check consistence of case and retag
-            self._check_case_validity(case_id)
+        # Check consistence of case and retag
+        self._check_case_validity(case_id)
 
-        except SetDataException, err:
-            # Do nothing than setting the status message. In the future the
-            # exception can be used to fill out the form again with htmlfill,
-            # which will clean up the renderer code a lot! But this is for the
-            # future
-            session['uncommited_fields'] = instance_tree.commit()
-            session.save()
-
         phase_changed = self._handle_automatic_phase_change(page_id)
         if phase_changed:
             return phase_changed



More information about the Mpuls-commits mailing list