[Mpuls-commits] r1737 - in wasko/branches/2.0: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 24 11:51:28 CET 2010


Author: bh
Date: 2010-02-24 11:51:27 +0100 (Wed, 24 Feb 2010)
New Revision: 1737

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/mpulsweb/lib/renderer.py
Log:
* mpulsweb/lib/renderer.py (ViewRenderer._renderText)
(ViewRenderer._renderDate, ViewRenderer._renderInt)
(ViewRenderer._renderRadio, ViewRenderer._renderPlainBool)
(ViewRenderer._renderChoice, ViewRenderer._renderChoiceGroup)
(ViewRenderer._renderChoiceBool, ViewRenderer._renderMatrix)
(ViewRenderer._renderMatrix)
(ViewRenderer._renderExternalChoiceList): Reduce number of local
variables.  Remove some unused ones.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-02-24 10:49:10 UTC (rev 1736)
+++ wasko/branches/2.0/ChangeLog	2010-02-24 10:51:27 UTC (rev 1737)
@@ -1,3 +1,14 @@
+2010-02-24  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/lib/renderer.py (ViewRenderer._renderText)
+	(ViewRenderer._renderDate, ViewRenderer._renderInt)
+	(ViewRenderer._renderRadio, ViewRenderer._renderPlainBool)
+	(ViewRenderer._renderChoice, ViewRenderer._renderChoiceGroup)
+	(ViewRenderer._renderChoiceBool, ViewRenderer._renderMatrix)
+	(ViewRenderer._renderMatrix)
+	(ViewRenderer._renderExternalChoiceList): Reduce number of local
+	variables.  Remove some unused ones.
+
 2010-02-24  Torsten Irländer <torsten.irlaender at intevation.de>
 
 	* jmd.json: Added rule definitions to the phase configuration

Modified: wasko/branches/2.0/mpulsweb/lib/renderer.py
===================================================================
--- wasko/branches/2.0/mpulsweb/lib/renderer.py	2010-02-24 10:49:10 UTC (rev 1736)
+++ wasko/branches/2.0/mpulsweb/lib/renderer.py	2010-02-24 10:51:27 UTC (rev 1737)
@@ -488,15 +488,12 @@
         meta = self._getMeta(node)
         out = []
         id = node.getIdentifier()
-        data = node.getValue() or ""
-        size = meta.getSize()
-        disabled = self.ro_mode and "disabled" or ""
-        maxlength = meta.getMaxLength()
         out.append(self._renderLabel(node))
         out.append(self._renderAttributes(node))
         out.append('<br>')
-        out.append(tag("input", name=id, id=id, value=data, type="text",
-                       size=size, maxlength=maxlength, disabled=self.ro_mode))
+        out.append(tag("input", name=id, id=id, value=node.getValue(),
+                       type="text", size=meta.getSize(),
+                       maxlength=meta.getMaxLength(), disabled=self.ro_mode))
         out.append('<br>')
         out.append(self._renderErrors(node))
         self.toTarget(Item("".join(out)), meta.getTarget())
@@ -505,14 +502,13 @@
         meta = self._getMeta(node)
         out = []
         id = node.getIdentifier()
-        data = node.getValue() or ""
         size = "10"
-        disabled = self.ro_mode and "disabled" or ""
         maxlength = "10"
         out.append(self._renderLabel(node))
         out.append(self._renderAttributes(node))
         out.append('<br>')
-        out.append(tag("input", name=id, id=id, value=format_date(data),
+        out.append(tag("input", name=id, id=id,
+                       value=format_date(node.getValue()),
                        type="text", size=size, maxlength=maxlength,
                        disabled=self.ro_mode, class_="datefield"))
         out.append('<br>')
@@ -523,13 +519,11 @@
         meta = self._getMeta(node)
         out = []
         id = node.getIdentifier()
-        data = node.getValue() or ""
-        disabled = self.ro_mode and "disabled" or ""
         out.append(self._renderLabel(node))
         out.append(self._renderAttributes(node))
         out.append('<br>')
-        out.append(tag("input", name=id, id=id, value=data, type="text",
-                       disabled=self.ro_mode))
+        out.append(tag("input", name=id, id=id, value=node.getValue(),
+                       type="text", disabled=self.ro_mode))
         out.append('<br>')
         out.append(self._renderErrors(node))
         self.toTarget(Item("".join(out)), meta.getTarget())
@@ -561,13 +555,11 @@
 
     def _renderRadio(self, node):
         meta = self._getMeta(node)
-        disabled = self.ro_mode and "disabled" or ""
         self.stateStack.append(node.getValue())
         out = []
         for child in node.getChildren():
             id = child.getIdentifier()
             value = self._getMeta(child).getValue()
-            checked = self.stateStack[-1] == value and 'checked="checked"' or ''
             out.append(tag("input", type="radio", id=id, name=id,
                            value=value, disabled=self.ro_mode,
                            checked=self.stateStack[-1] == value,
@@ -585,10 +577,8 @@
         id = node.getIdentifier()
         mvalue = meta.getValue()
         value = node.getValue()
-        disabled = self.ro_mode and "disabled" or ""
         #checked = self.stateStack[-1] == value and "checked" or ""
         #print "mvalue: %s value: %s" % (mvalue, value)
-        checked = mvalue == value and "checked" or ""
         out = []
         out.append(tag("input", type="checkbox", id=id, name=id,
                        value=mvalue, disabled=self.ro_mode,
@@ -606,20 +596,15 @@
     def _renderChoice(self, node):
         meta = self._getMeta(node)
         id = node.getIdentifier()
-        value = node.getValue()
-        description = meta.getDescription()
-        size = meta.getSize() or "1"
-        multiple = meta.getMultiple() and "multiple" or ""
-        disabled = self.ro_mode and "disabled" or ""
 
         out = []
         out.append(self._renderLabel(node))
         out.append(self._renderAttributes(node))
         out.append('<br>')
-        out.append(tag("select", id=id, name=id, size=size,
+        out.append(tag("select", id=id, name=id, size=meta.getSize() or "1",
                        multiple=bool(meta.getMultiple()), disabled=self.ro_mode,
                        **SET_MODIFICATION_ATTRS))
-        self.stateStack.append(str(value))
+        self.stateStack.append(str(node.getValue()))
         out.append(self._renderRecursive(meta, False, ChoiceContainer))
         #for child in meta.children:
         #    if isinstance(child, data.ExternalChoiceListLeaf):
@@ -638,11 +623,9 @@
 
     def _renderChoiceGroup(self, choice):
         meta = self._getMeta(choice)
-        description = meta.getDescription()
-        name = meta.getName()
         out = []
         if not self.ro_mode:
-            out.append(tag("optgroup", label=description))
+            out.append(tag("optgroup", label=meta.getDescription()))
             out.append("\n")
         out.append(self._renderRecursive(meta, False, ChoiceContainer))
         if not self.ro_mode:
@@ -653,7 +636,6 @@
         meta = self._getMeta(bool)
 
         description = meta.getDescription()
-        name = meta.getName()
         value = meta.getValue()
         selected = ""
         out = ""
@@ -685,8 +667,6 @@
 
     def _renderMatrix(self, node):
         meta = self._getMeta(node)
-        description = meta.getDescription()
-        disabled = self.ro_mode and "disabled" or ""
         out = []
         legend = []
         out.append('<table class="radiomatrix">')
@@ -719,12 +699,9 @@
             out.append('</td>')
             self.stateStack.append(str(row.getValue()))
             for col in self._getMeta(row).children:
-                name = row.getIdentifier()
-                name = name
                 value = col.getValue()
-                checked = value == self.stateStack[-1] and "checked" or ""
                 out.append('<td class="%s">' % (num%2 and "hl" or ""))
-                out.append(tag("input", type="radio", name=name,
+                out.append(tag("input", type="radio", name=row.getIdentifier(),
                                value=value, disabled=self.ro_mode,
                                checked=(value == self.stateStack[-1]),
                                tabindex=self.next_tabindex(),
@@ -779,12 +756,9 @@
         if children:
             for child in children:
                 value = child.getValue()
-                label = child.getDescription()
-                selected = ((value == self.stateStack[-1])
-                            and 'selected="selected"' or '')
                 out.append(tag("option", value=value,
                                selected=(value == self.stateStack[-1])))
-                out.append(escape(label))
+                out.append(escape(child.getDescription()))
                 out.append("</option>")
         return out
 



More information about the Mpuls-commits mailing list