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

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


Author: bh
Date: 2010-09-27 20:41:41 +0200 (Mon, 27 Sep 2010)
New Revision: 3796

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/controllers/formularpage.py
Log:
* mpulsweb/controllers/formularpage.py: Formatting.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-09-27 18:32:48 UTC (rev 3795)
+++ base/trunk/ChangeLog	2010-09-27 18:41:41 UTC (rev 3796)
@@ -1,5 +1,9 @@
 2010-09-27  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/controllers/formularpage.py: Formatting.
+
+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

Modified: base/trunk/mpulsweb/controllers/formularpage.py
===================================================================
--- base/trunk/mpulsweb/controllers/formularpage.py	2010-09-27 18:32:48 UTC (rev 3795)
+++ base/trunk/mpulsweb/controllers/formularpage.py	2010-09-27 18:41:41 UTC (rev 3796)
@@ -48,7 +48,8 @@
     result = {}
     for i in params:
         # libformed
-        if i not in ['save', 'savenext', 'page'] and not i.startswith(('add_rg', 'del_rg')):
+        if (i not in ['save', 'savenext', 'page']
+            and not i.startswith(('add_rg', 'del_rg'))):
             result[i] = params[i]
     return result
 
@@ -85,8 +86,7 @@
         page_label = page.getMeta().getDescription()
         if isinstance(page.getParent(), RepeatInstanceNode):
             page_label += " %s" % get_child_num(page.getParent())
-        c.formularheader = ("<h1>%s</h1>"
-                            % escape(page_label))
+        c.formularheader = ("<h1>%s</h1>" % escape(page_label))
         if isinstance(page, RepeatInstanceContainerNode):
             renderer = RepeatGroupRenderer(instance_tree, page,
                                            session.get('render_mode',
@@ -122,29 +122,27 @@
     # Currently values of the fields are set within the renderer.
     # Htmlfill is used to fill in the error values from the error items.
     defaults = prepare_htmlfill_defaults(defaults)
-    
+
     # Parse the real errors
-    parsedForm = formencode.htmlfill.render(form,
-                                            defaults           = defaults,
-                                            errors             = errors,
-                                            auto_insert_errors = False,
-                                            force_defaults     = False)
-    
+    parsedForm = formencode.htmlfill.render(form, defaults=defaults,
+                                            errors=errors,
+                                            auto_insert_errors=False,
+                                            force_defaults=False)
+
     # Replace "form:warnings" with "form:errors" so that htmlfill understands it
     parsedForm = parsedForm.replace('form:warning', 'form:error')
-    
+
     # make a new dictionary because the warnings have the warning text in a (one
     #element) list
     warningList = {}
     for i in renderer.warnings.keys():
         warningList[i] = renderer.warnings[i][0]
-    
+
     # Let htmlfill parse the form again
-    parsedForm = formencode.htmlfill.render(parsedForm,
-                                            errors             = warningList,
-                                            error_class        = 'warning',
-                                            auto_insert_errors = False,
-                                            force_defaults     = False)
+    parsedForm = formencode.htmlfill.render(parsedForm, errors=warningList,
+                                            error_class='warning',
+                                            auto_insert_errors=False,
+                                            force_defaults=False)
     return parsedForm
 
 
@@ -205,7 +203,7 @@
             instance_tree.setData(form_result)
             session['uncommited_fields'] = instance_tree.commit()
             session.save()
-            
+
             # How to proceed after saving the data?
             self._handle_repeat_group_redirects()
 
@@ -220,7 +218,6 @@
             # 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
-            #error_status(_('Error while saving data'))
             session['uncommited_fields'] = instance_tree.commit()
             session.save()
 
@@ -255,8 +252,8 @@
             log.debug(g.mpuls_config.get('phases', 'description'))
             reachable_phase = phases.get_max_phase_id()
             if current_phase != reachable_phase:
-                cpd = phases.get_phase(current_phase).getDescription() 
-                rpd = phases.get_phase(reachable_phase).getDescription() 
+                cpd = phases.get_phase(current_phase).getDescription()
+                rpd = phases.get_phase(reachable_phase).getDescription()
                 if changemode == PC_FULLAUTO:
                     log.debug("fullautomatic phase change!")
                     #load case and set phase
@@ -264,25 +261,22 @@
                     case.getState().setPhase(reachable_phase)
                     # build dialog
                     c.dialog_title = DIALOG_FULLAUTOMATIC_CHANGE_TITLE
-                    c.dialog_text = DIALOG_FULLAUTOMATIC_CHANGE_TEXT \
-                    % (cpd, rpd)
-                    c.url_ok = url_for(controller="formularpage", 
-                                         action="select", 
-                                         id=page_id)  
+                    c.dialog_text = (DIALOG_FULLAUTOMATIC_CHANGE_TEXT
+                                     % (cpd, rpd))
+                    c.url_ok = url_for(controller="formularpage",
+                                       action="select", id=page_id)
                     return render('/phase/dialogs/success_fullautomatic_set_phase.mako')
                 else:
                     log.debug("halfautomatic phase change!")
                     # build dialog
-                    c.dialog_title = DIALOG_HALFAUTOMATIC_CHANGE_TITLE 
-                    c.dialog_text = DIALOG_HALFAUTOMATIC_CHANGE_TEXT \
-                    % (cpd, rpd)
-                    c.url_ok = url_for(controller="phase", 
-                                         action="setPhase", 
-                                         id=session['case'].id,
-                                         value=reachable_phase)  
-                    c.url_no = url_for(controller="formularpage", 
-                                         action="select", 
-                                         id=page_id)
+                    c.dialog_title = DIALOG_HALFAUTOMATIC_CHANGE_TITLE
+                    c.dialog_text = (DIALOG_HALFAUTOMATIC_CHANGE_TEXT
+                                     % (cpd, rpd))
+                    c.url_ok = url_for(controller="phase", action="setPhase",
+                                       id=session['case'].id,
+                                       value=reachable_phase)
+                    c.url_no = url_for(controller="formularpage",
+                                       action="select", id=page_id)
                     return render('/phase/dialogs/success_halfautomatic_set_phase.mako')
         return None
 



More information about the Mpuls-commits mailing list