[Mpuls-commits] r2013 - in wasko/branches/2.0: . mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Mar 18 20:23:29 CET 2010
Author: bh
Date: 2010-03-18 20:23:29 +0100 (Thu, 18 Mar 2010)
New Revision: 2013
Modified:
wasko/branches/2.0/ChangeLog
wasko/branches/2.0/mpulsweb/lib/renderer.py
Log:
* mpulsweb/lib/renderer.py (ViewRenderer.__init__): Add instance
variable for warnings
(ViewRenderer._checkWarnings): New. Checks a given node for
warnings by evaluating warning and notice rules.
(ViewRenderer._renderChild): Call _checkWarnings for all children.
The child object may actually be a meta node, so the
_checkWarnings method has to check for that.
Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog 2010-03-18 19:13:44 UTC (rev 2012)
+++ wasko/branches/2.0/ChangeLog 2010-03-18 19:23:29 UTC (rev 2013)
@@ -1,5 +1,15 @@
2010-03-18 Bernhard Herzog <bh at intevation.de>
+ * mpulsweb/lib/renderer.py (ViewRenderer.__init__): Add instance
+ variable for warnings
+ (ViewRenderer._checkWarnings): New. Checks a given node for
+ warnings by evaluating warning and notice rules.
+ (ViewRenderer._renderChild): Call _checkWarnings for all children.
+ The child object may actually be a meta node, so the
+ _checkWarnings method has to check for that.
+
+2010-03-18 Bernhard Herzog <bh at intevation.de>
+
* mpulsweb/lib/renderer.py (ViewRenderer._renderConditional):
Evaluating conditionals is now handled in libformed, so we do not
need to do manually here. Requires revision 107:1bc2755896f8 of
Modified: wasko/branches/2.0/mpulsweb/lib/renderer.py
===================================================================
--- wasko/branches/2.0/mpulsweb/lib/renderer.py 2010-03-18 19:13:44 UTC (rev 2012)
+++ wasko/branches/2.0/mpulsweb/lib/renderer.py 2010-03-18 19:23:29 UTC (rev 2013)
@@ -219,6 +219,7 @@
self.containersStack = None
self.ro_mode = ro_mode
self.tabindex = 3
+ self.warnings = {}
def next_tabindex(self):
tabindex = self.tabindex
@@ -340,6 +341,34 @@
out.append('</span>')
return "".join(out)
+ def _checkWarnings(self, node):
+ """Check node for warnings by evaluating the relevant warning rules.
+ Only rules that are warnings, as determined by the rule's
+ isWarning method, and that would mark the field corresponding to
+ node are evaluated. If such a rule is violated the warning
+ message is added to the self.warnings dictionary.
+ """
+ meta = self._getMeta(node)
+ if meta is node:
+ # This method is called from _renderChild for all child
+ # object, some of which are actually meta tree components.
+ # We cannot check warnings on meta components, so abort
+ # early in this case.
+ return
+
+ name = meta.getName()
+ id = node.getIdentifier()
+ formed = self.it.getFormEd()
+ rules = [rule for rule in formed.name2markingrules.get(name, ())
+ if rule.isWarning()]
+ if not rules:
+ return
+
+ context = RuleEvalContext(self.it, id)
+ for rule in rules:
+ if not rule.getExpr().evaluate(context):
+ self.warnings[id] = rule.getValue()
+
def _renderGroup(self, node):
meta = self._getMeta(node)
description = meta.getDescription()
@@ -763,6 +792,7 @@
self._getMeta(choiceList).getTarget())
def _renderChild(self, child):
+ self._checkWarnings(child)
meta = self._getMeta(child)
if isinstance(child, RepeatInstanceContainerNode):
self._renderRepeatContainer(child)
More information about the Mpuls-commits
mailing list