[Mpuls-commits] r5989 - base/trunk/mpulsweb/controllers

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Fri Jun 15 11:23:23 CEST 2012


Author: bricks
Date: 2012-06-15 11:23:22 +0200 (Fri, 15 Jun 2012)
New Revision: 5989

Modified:
   base/trunk/mpulsweb/controllers/formularpage.py
Log:
Remove duplicated code

get_rendered_page references PageRenderers get_rendered_page method now.


Modified: base/trunk/mpulsweb/controllers/formularpage.py
===================================================================
--- base/trunk/mpulsweb/controllers/formularpage.py	2012-06-15 08:02:10 UTC (rev 5988)
+++ base/trunk/mpulsweb/controllers/formularpage.py	2012-06-15 09:23:22 UTC (rev 5989)
@@ -44,67 +44,8 @@
     return result
 
 
-def get_rendered_page(id, instance_tree=None, viewrenderer=ViewRenderer,
-                      rgrenderer=RepeatGroupRenderer,
-                      printrenderer=ViewPrintRenderer,
-                      errorrenderer=ErrorRenderer):
-    if instance_tree is None:
-        factory = g.get_instance_factory()
-        instance_tree = factory.loadInstanceTreeByIdentifier(
-            session['case'].id,
-            session.get('uncommited_fields'))
+get_rendered_page = PageRenderer().get_rendered_page
 
-    log.debug('Getting page "%s"' % id)
-    page = instance_tree.getItem(id)
-
-    # Abort with a 404 HTTP response if the page wasn't found. abort
-    # raises an exception, so in the code after this branch we can
-    # assume that the page was found.
-    if not page:
-        log.error('Page not found %s' % id)
-        abort(404)
-
-    page_label = page.getMeta().getDescription()
-
-    url_factory = UrlFactory()
-    renderer_kw_args = dict(read_only=session.get('render_mode', 'ro') == 'ro',
-                            languages=get_lang())
-    if isinstance(page, RepeatInstanceContainerNode):
-        formdata = TreeFormData(instance_tree)
-        renderer = rgrenderer(formdata, page.getMeta(), url_factory,
-                              **renderer_kw_args)
-        errors = {}
-        defaults = {}
-    else:
-        errors, defaults = convert_error_items(page.getErrors())
-        formdata = TreeFormData(instance_tree, shadow=defaults, errors=errors,
-                                node=page)
-        if c.print_version:
-            renderer = printrenderer(formdata, page.getMeta(), url_factory,
-                                     **renderer_kw_args)
-        else:
-            renderer = viewrenderer(formdata, page.getMeta(), url_factory,
-                                    **renderer_kw_args)
-
-    navigation_item = session['navigation.tree'].getTreeItem(id)
-    mark_folderopen(navigation_item)
-
-    c.formularheader = renderer.render_page_headings()
-    c.formular = renderer.render(show_next=navigation_item.nextKey(),
-                                 hidden_fields=[("page", page.getIdentifier())])
-
-    error_renderer = errorrenderer(formdata, g.formedTree, errors,
-                                   renderer.warnings, renderer.notices,
-                                   renderer.widget_order, url_factory,
-                                   languages=get_lang())
-    c.formularerrors = error_renderer.render()
-    c.page_id = page.getIdentifier()
-    session['navigation.selectedpage'] = id
-    session.save()
-
-    return render('/formularpage/content.mako')
-
-
 class PageRenderer(object):
 
     def __init__(self):



More information about the Mpuls-commits mailing list