[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - vocabularywidget.py:1.35

Fred L. Drake, Jr. fred@zope.com
Fri, 6 Jun 2003 17:07:26 -0400


Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv22905

Modified Files:
	vocabularywidget.py 
Log Message:
Split mkselectionlist() into two method; one that formats the group of
items, and one that formats a single item.  This should make
subclassing easier.


=== Zope3/src/zope/app/browser/form/vocabularywidget.py 1.34 => 1.35 ===
--- Zope3/src/zope/app/browser/form/vocabularywidget.py:1.34	Fri Jun  6 16:16:30 2003
+++ Zope3/src/zope/app/browser/form/vocabularywidget.py	Fri Jun  6 17:07:25 2003
@@ -133,20 +133,20 @@
         return term.token
 
     def mkselectionlist(self, type, info, name):
-        L = ["<table>\n"]
-        for term, selected, disabled in info:
-            flag = ""
-            if selected:
-                flag = "checked "
-            if disabled:
-                flag += "disabled "
-            L.append("<tr><td>"
-                     "<input type='%s' value='%s' name='%s' %s/>"
-                     "</td>\n    <td>%s</td>"
-                     "</tr>\n"
-                     % (type, term.token, name, flag, self.textForValue(term)))
-        L.append("</table>")
-        return ''.join(L)
+        L = [self.mkselectionitem(type, name, *item) for item in info]
+        return widget.renderElement("table",
+                                    contents="\n%s\n" % "\n".join(L))
+
+    def mkselectionitem(self, type, name, term, selected, disabled):
+        flag = ""
+        if selected:
+            flag = "checked "
+        if disabled:
+            flag += "disabled "
+        return ("<tr><td>"
+                "<input type='%s' value='%s' name='%s' %s/>"
+                "</td>\n    <td>%s</td></tr>"
+                % (type, term.token, name, flag, self.textForValue(term)))
 
 
 class VocabularyWidgetBase(ViewSupport, widget.BrowserWidget):