[Mpuls-commits] r3191 - in base/trunk: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jul 16 18:23:50 CEST 2010


Author: bh
Date: 2010-07-16 18:23:46 +0200 (Fri, 16 Jul 2010)
New Revision: 3191

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/renderer.py
Log:
* mpulsweb/lib/renderer.py (ViewRenderer._renderChoiceBool):
rework this method almost completely.  It's much shorter now but
should work in the same way. This change also gets rid of some
strange expressions and, like the rest of the renderer, now uses
the tag function to create opening tags.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-07-15 12:45:05 UTC (rev 3190)
+++ base/trunk/ChangeLog	2010-07-16 16:23:46 UTC (rev 3191)
@@ -1,3 +1,11 @@
+2010-07-16  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/lib/renderer.py (ViewRenderer._renderChoiceBool):
+	rework this method almost completely.  It's much shorter now but
+	should work in the same way. This change also gets rid of some
+	strange expressions and, like the rest of the renderer, now uses
+	the tag function to create opening tags.
+
 2010-07-12  Torsten Irländer <torsten.irlaender at intevation.de>
 
 	* mpulsweb/lib/helper/case.py: Adding helper functions to work on

Modified: base/trunk/mpulsweb/lib/renderer.py
===================================================================
--- base/trunk/mpulsweb/lib/renderer.py	2010-07-15 12:45:05 UTC (rev 3190)
+++ base/trunk/mpulsweb/lib/renderer.py	2010-07-16 16:23:46 UTC (rev 3191)
@@ -663,40 +663,16 @@
 
     def _renderChoiceBool(self, bool):
         meta = self._getMeta(bool)
-
-        description = meta.getDescription()
         value = meta.getValue()
-        selected = ""
-        out = ""
+        selected = value == self.stateStack[-1]
+        out = []
+        if not self.ro_mode or selected:
+            out.append(tag("option", selected=selected, value=value))
+            out.append(escape(meta.getDescription()))
+            out.append("</option>")
 
-        try:
-            toSelect = self.stateStack[-1]
-        except:
-            toSelect = None
-        selected = toSelect == (value or value==0) and "selected" or ""
+        self.toTarget(Text("".join(out)), meta.getTarget())
 
-        if selected:
-            selected = selected + '="' + selected + '"'
-
-        if (value or value==0):
-            value = 'value="%s"' % escape(value, True)
-        else:
-            value = ""
-
-        if description:
-            description = escape(description)
-        else:
-            description = ""
-
-        if self.ro_mode:
-            if selected:
-                out = ("<option %s %s>%s</option>\n"
-                       % (value, selected, description))
-        else:
-            out = "<option %s %s>%s</option>\n" % (value, selected, description)
-
-        self.toTarget(Text(out), meta.getTarget())
-
     def _renderMatrix(self, node):
         meta = self._getMeta(node)
         out = []



More information about the Mpuls-commits mailing list