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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Sep 27 20:32:49 CEST 2010


Author: bh
Date: 2010-09-27 20:32:48 +0200 (Mon, 27 Sep 2010)
New Revision: 3795

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/controllers/formularpage.py
Log:
* mpulsweb/controllers/formularpage.py
(FormularpageController._before_set_data_hook): New.  Hook method
to make it easier for derived classes to influence the behavior of
the save method.
(FormularpageController.save): Call _before_set_data_hook before
actually setting the data.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-09-27 18:30:07 UTC (rev 3794)
+++ base/trunk/ChangeLog	2010-09-27 18:32:48 UTC (rev 3795)
@@ -1,5 +1,14 @@
 2010-09-27  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/controllers/formularpage.py
+	(FormularpageController._before_set_data_hook): New.  Hook method
+	to make it easier for derived classes to influence the behavior of
+	the save method.
+	(FormularpageController.save): Call _before_set_data_hook before
+	actually setting the data.
+
+2010-09-27  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/controllers/formularpage.py: Introduce case_id variable
 	to avoid duplicating the code to retrieve it.
 

Modified: base/trunk/mpulsweb/controllers/formularpage.py
===================================================================
--- base/trunk/mpulsweb/controllers/formularpage.py	2010-09-27 18:30:07 UTC (rev 3794)
+++ base/trunk/mpulsweb/controllers/formularpage.py	2010-09-27 18:32:48 UTC (rev 3795)
@@ -200,6 +200,8 @@
             form_result = convert2dic(request.params)
             apply_hidden_booleans(form_result)
 
+            self._before_set_data_hook(case_id, form_result)
+
             instance_tree.setData(form_result)
             session['uncommited_fields'] = instance_tree.commit()
             session.save()
@@ -228,6 +230,12 @@
 
         return self.select(page_id)
 
+    def _before_set_data_hook(self, case_id, form_result):
+        """Modify the form_result dict of the save method before it's applied.
+        Override in derived classes to handle application specific
+        special cases.  The default implementation does nothing.
+        """
+
     def _check_case_validity(self, case_id):
         """Check validity of the case given by case_id.
         If the checktags case-module is not enabled, this method does nothing.



More information about the Mpuls-commits mailing list