[Mpuls-commits] r1418 - in wasko/branches/2.0: . waskaweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Feb 9 17:10:22 CET 2010


Author: bh
Date: 2010-02-09 17:10:18 +0100 (Tue, 09 Feb 2010)
New Revision: 1418

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/waskaweb/controllers/formularpage.py
Log:
* waskaweb/controllers/formularpage.py: Fix formatting.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-02-09 16:03:34 UTC (rev 1417)
+++ wasko/branches/2.0/ChangeLog	2010-02-09 16:10:18 UTC (rev 1418)
@@ -1,5 +1,9 @@
 2010-02-09  Bernhard Herzog  <bh at intevation.de>
 
+	* waskaweb/controllers/formularpage.py: Fix formatting.
+
+2010-02-09  Bernhard Herzog  <bh at intevation.de>
+
 	* waskaweb/controllers/repeatgroup.py (RepeatgroupController.new):
 	The first parameter for abort has to be an int, not a string.
 

Modified: wasko/branches/2.0/waskaweb/controllers/formularpage.py
===================================================================
--- wasko/branches/2.0/waskaweb/controllers/formularpage.py	2010-02-09 16:03:34 UTC (rev 1417)
+++ wasko/branches/2.0/waskaweb/controllers/formularpage.py	2010-02-09 16:10:18 UTC (rev 1418)
@@ -2,26 +2,32 @@
 
 import logging
 import traceback
+
 import formencode
 
 from pylons import request, response, session, c
 from pylons import g
 from pylons.i18n import _
 from pylons.controllers.util import abort, redirect_to
-from mpulsweb.lib.security          import checkRole
 
-from waskaweb.lib.base import BaseController, render
-from mpulsweb.lib.db import  PostgresDBInterface
-from mpulsweb.lib.navigation import  mark_folderopen 
-
-from waskaweb.lib.renderer import  ViewRenderer, RepeatGroupRenderer, ErrorRenderer
 from formed.instance.backends.postgres import DBFactory as InstanceFactory
 from formed.instance.tree import SetDataException, RepeatInstanceContainerNode
 
+from mpulsweb.lib.security import checkRole
+from mpulsweb.lib.db import  PostgresDBInterface
+from mpulsweb.lib.navigation import  mark_folderopen
+
+from waskaweb.lib.base import BaseController, render
+from waskaweb.lib.renderer import ViewRenderer, RepeatGroupRenderer, \
+     ErrorRenderer
+
+
 log = logging.getLogger(__name__)
 
+
 def convertErrorItem2ErrorDic(error_items):
-    if error_items is None: return {}
+    if error_items is None:
+        return {}
     errors = {}
     print error_items
     for items in error_items:
@@ -31,7 +37,8 @@
     return errors
 
 def convertErrorItem2WarningDic(error_items):
-    if error_items is None: return {}
+    if error_items is None:
+        return {}
     errors = {}
     print error_items
     for items in error_items:
@@ -41,7 +48,8 @@
     return errors
 
 def convertErrorItem2ValueDic(error_items):
-    if error_items is None: return {}
+    if error_items is None:
+        return {}
     errors = {}
     print error_items
     for items in error_items:
@@ -53,60 +61,61 @@
 def convert2dic(params):
     result = {}
     for i in params:
-        # libformed 
-        if i not in ['save','savenext','page']:
-            result[i] = params[i] 
+        # libformed
+        if i not in ['save', 'savenext', 'page']:
+            result[i] = params[i]
     return result
 
 def get_rendered_page(id):
     factory = InstanceFactory(g.formedTree, PostgresDBInterface())
     instance_tree = factory.loadInstanceTreeByIdentifier(
-        session['case'].id, 
+        session['case'].id,
         session.get('uncommited_fields'))
 
     log.debug('Getting page "%s"' % id)
     page = instance_tree.getItem(id)
 
-    errors   = convertErrorItem2ErrorDic(page.getErrors()) 
+    errors = convertErrorItem2ErrorDic(page.getErrors())
     warnings = convertErrorItem2WarningDic(page.getErrors())
     defaults = convertErrorItem2ValueDic(page.getErrors())
 
     if page:
         c.formularheader = "<h1>%s</h1>" % page.getMeta().getDescription()
         if isinstance(page, RepeatInstanceContainerNode):
-            renderer      = RepeatGroupRenderer(instance_tree, page,session.get('render_mode', 'ro')=='ro')
+            renderer = RepeatGroupRenderer(instance_tree, page,
+                                           session.get('render_mode',
+                                                       'ro') == 'ro')
         else:
-            c.formularerrors = u"Fehler" 
-            renderer      = ViewRenderer(instance_tree, page,session.get('render_mode', 'ro')=='ro')
-        errorrenderer = ErrorRenderer(errors, warnings) 
-        c.formularerrors = errorrenderer.render(page) 
+            c.formularerrors = u"Fehler"
+            renderer = ViewRenderer(instance_tree, page,
+                                    session.get('render_mode', 'ro') == 'ro')
+        errorrenderer = ErrorRenderer(errors, warnings)
+        c.formularerrors = errorrenderer.render(page)
         try:
-            mark_folderopen(session['navigation.tree'].getTreeItem(id)) 
+            mark_folderopen(session['navigation.tree'].getTreeItem(id))
             if session['navigation.tree'].getTreeItem(id).nextKey():
-                c.formular    = renderer.render(showNext=True)
+                c.formular = renderer.render(showNext=True)
             else:
-                c.formular    = renderer.render(showNext=False)
+                c.formular = renderer.render(showNext=False)
         except:
-            print traceback.print_exc() 
-        c.page_id = page.getIdentifier() 
+            print traceback.print_exc()
+        c.page_id = page.getIdentifier()
         session['case'].setPageId(c.page_id)
         session['navigation.selectedpage'] = id
         session.save()
 
-    # Render form and use htmlfill to fillout the form and mark errorfields. 
+    # Render form and use htmlfill to fillout the form and mark errorfields.
     form = unicode(render('/formularpage/content.mako'), 'utf-8')
 
-    # Currently values of the fields are set within the renderer. 
+    # Currently values of the fields are set within the renderer.
     # Htmlfill is used to fill in the error values from the error items.
-    return formencode.htmlfill.render(form,
-        defaults=defaults, \
-        errors=errors,
-        auto_insert_errors=False, 
-        force_defaults=False)
+    return formencode.htmlfill.render(form, defaults=defaults,
+                                      errors=errors, auto_insert_errors=False,
+                                      force_defaults=False)
 
+
 class FormularpageController(BaseController):
 
-
     def index(self):
         # Return a rendered template
         # return render('/formularpage.mako')
@@ -125,7 +134,7 @@
         try:
             return self.select(id)
         except:
-            print traceback.print_exc() 
+            print traceback.print_exc()
 
     @checkRole(('admin_ka', 'cm_ka', 'pt_dlr'))
     def show(self, id):
@@ -137,7 +146,7 @@
     def undo(self, id):
         try:
             unc = session.get('uncommited_fields')
-            if unc: 
+            if unc:
                 del unc[id]
                 session['uncommited_fields'] = unc
                 session.save()
@@ -149,7 +158,7 @@
     def save(self):
         factory = InstanceFactory(g.formedTree, PostgresDBInterface())
         instance_tree = factory.loadInstanceTreeByIdentifier(
-            session['case'].id, 
+            session['case'].id,
             session.get('uncommited_fields'))
         page_id = request.params['page']
         try:
@@ -184,6 +193,6 @@
         session['render_mode'] = 'ro'
         session.save()
         page = self.select(id)
-        session['render_mode'] = render_mode 
+        session['render_mode'] = render_mode
         session.save()
-        return page 
+        return page



More information about the Mpuls-commits mailing list