[Mpuls-commits] r4489 - base/trunk/mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Jan 11 14:51:49 CET 2011


Author: torsten
Date: 2011-01-11 14:51:48 +0100 (Tue, 11 Jan 2011)
New Revision: 4489

Modified:
   base/trunk/mpulsweb/lib/renderer.py
Log:
* mpulsweb/lib/renderer.py (ViewRenderer._renderChild): Try to save
	the identifier of the current element which is about to be rendered.
	This is part of a hack to enable rendering of conditionals in choice
	lists.
* mpulsweb/lib/renderer.py (ViewRenderer._renderConditional): If the
	rendered conditional is a Meta Object call evaluat function wih saved
	curr_identfier.


Modified: base/trunk/mpulsweb/lib/renderer.py
===================================================================
--- base/trunk/mpulsweb/lib/renderer.py	2011-01-11 11:54:19 UTC (rev 4488)
+++ base/trunk/mpulsweb/lib/renderer.py	2011-01-11 13:51:48 UTC (rev 4489)
@@ -184,6 +184,7 @@
         self.warnings = {}
         self.notices = {}
         self.widget_order = []
+        self.current_identifier = None
 
     def next_tabindex(self):
         tabindex = self.tabindex
@@ -502,7 +503,11 @@
         return out
 
     def _renderConditional(self, conditional):
-        if not self.it.evaluate_conditional(conditional):
+        if isinstance(conditional, MetaNodeComponent):
+            valid = self.it.evaluate_conditional(conditional, self.current_identifier)
+        else:
+            valid = self.it.evaluate_conditional(conditional)
+        if not valid:
             meta = self._getMeta(conditional)
             ro = not meta.isInvisible()
             if ro:
@@ -816,6 +821,7 @@
         # Check if the bool is within a choicelist
         if (isinstance(self._getMeta(parent), data.ChoiceNode)
             or isinstance(self._getMeta(parent), data.GroupNode)
+            or isinstance(self._getMeta(parent), data.ConditionalNode)
             and isinstance(self._getMeta(parentparent), data.ChoiceNode)):
             self._renderChoiceBool(bool)
 
@@ -844,6 +850,12 @@
                       self._getMeta(choiceList).getTarget())
 
     def _renderChild(self, child):
+        try:
+            # Try to get the identiefier for the current element.
+            self.current_identifier = child.getIdentifier()
+        except Exception, e:
+            # May fail in case of meta objects.
+            pass
         self._checkWarnings(child)
         meta = self._getMeta(child)
         if isinstance(child, RepeatInstanceContainerNode):



More information about the Mpuls-commits mailing list