[Mpuls-commits] r5958 - base/trunk/mpulsweb/controllers
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Thu May 10 11:52:53 CEST 2012
Author: bricks
Date: 2012-05-10 11:52:53 +0200 (Thu, 10 May 2012)
New Revision: 5958
Modified:
base/trunk/mpulsweb/controllers/formularpage.py
Log:
Change get_rendered_page to be able to pass the renderer class
Allow to change the renderer classes in a mpuls instance. E.g.
mpuls_S will use a different ViewRenderer to change the rendering
of inline repeat groups.
Modified: base/trunk/mpulsweb/controllers/formularpage.py
===================================================================
--- base/trunk/mpulsweb/controllers/formularpage.py 2012-05-10 07:57:16 UTC (rev 5957)
+++ base/trunk/mpulsweb/controllers/formularpage.py 2012-05-10 09:52:53 UTC (rev 5958)
@@ -46,7 +46,10 @@
return result
-def get_rendered_page(id, instance_tree=None):
+def get_rendered_page(id, instance_tree=None, viewrenderer=ViewRenderer,
+ rgrenderer=RepeatGroupRenderer,
+ printrenderer=ViewPrintRenderer,
+ errorrenderer=ErrorRenderer):
if instance_tree is None:
factory = InstanceFactory(g.formedTree, PostgresDBInterface())
instance_tree = factory.loadInstanceTreeByIdentifier(
@@ -70,8 +73,8 @@
languages=get_lang())
if isinstance(page, RepeatInstanceContainerNode):
formdata = TreeFormData(instance_tree)
- renderer = RepeatGroupRenderer(formdata, page.getMeta(), url_factory,
- **renderer_kw_args)
+ renderer = rgrenderer(formdata, page.getMeta(), url_factory,
+ **renderer_kw_args)
errors = {}
defaults = {}
else:
@@ -79,10 +82,10 @@
formdata = TreeFormData(instance_tree, shadow=defaults, errors=errors,
node=page)
if c.print_version:
- renderer = ViewPrintRenderer(formdata, page.getMeta(), url_factory,
- **renderer_kw_args)
+ renderer = printrenderer(formdata, page.getMeta(), url_factory,
+ **renderer_kw_args)
else:
- renderer = ViewRenderer(formdata, page.getMeta(), url_factory,
+ renderer = viewrenderer(formdata, page.getMeta(), url_factory,
**renderer_kw_args)
navigation_item = session['navigation.tree'].getTreeItem(id)
@@ -92,7 +95,7 @@
c.formular = renderer.render(show_next=navigation_item.nextKey(),
hidden_fields=[("page", page.getIdentifier())])
- error_renderer = ErrorRenderer(formdata, g.formedTree, errors,
+ error_renderer = errorrenderer(formdata, g.formedTree, errors,
renderer.warnings, renderer.notices,
renderer.widget_order, url_factory,
languages=get_lang())
More information about the Mpuls-commits
mailing list