[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - widget.py:1.63

Fred L. Drake, Jr. fred at zope.com
Tue Jan 20 15:14:54 EST 2004


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

Modified Files:
	widget.py 
Log Message:
- don't use an extra element for the tooltip; setting the title on the
  <label/> element seems to be sufficient
- try not to generate extra whitespace in rendered elements


=== Zope3/src/zope/app/browser/form/widget.py 1.62 => 1.63 ===
--- Zope3/src/zope/app/browser/form/widget.py:1.62	Tue Jan 20 13:56:32 2004
+++ Zope3/src/zope/app/browser/form/widget.py	Tue Jan 20 15:14:53 2004
@@ -312,18 +312,12 @@
         self.setRenderedValue(value)
         return self.hidden()
 
-    def _tooltip(self, txt, description):
-        if description:
-            return '<span title="%s">%s</span>' % (
-                cgi.escape(description, quote=1), txt
-                )
-        else:
-            return txt
-
     def label(self):
-        return '<label for="%s">%s</label>' % (
-            self.name, self._tooltip(self.title,
-                                     self.context.description))
+        kw = {"for": self.name,
+              "contents": cgi.escape(self.title)}
+        if self.context.description:
+            kw["title"] = self.context.description
+        return renderElement("label", **kw)
 
     def error(self):
         if self._error:
@@ -1441,21 +1435,25 @@
 
     # special case handling for extra 'raw' code
     if 'extra' in kw:
-        extra = kw['extra'] # could be empty string but we don't care
+        extra = " " + kw['extra'] # could be empty string but we don't care
         del kw['extra']
     else:
         extra = ""
 
     # handle other attributes
-    items = kw.items()
-    items.sort()
-    for key, value in items:
-        if value == None:
-            value = key
-        attr_list.append('%s=%s' % (key, quoteattr(unicode(value))))
-
-    attr_str = " ".join(attr_list)
-    return "<%s %s %s" % (tag, attr_str, extra)
+    if kw:
+        items = kw.items()
+        items.sort()
+        for key, value in items:
+            if value == None:
+                value = key
+            attr_list.append('%s=%s' % (key, quoteattr(unicode(value))))
+
+    if attr_list:
+        attr_str = " ".join(attr_list)
+        return "<%s %s%s" % (tag, attr_str, extra)
+    else:
+        return "<%s%s" % (tag, extra)
 
 
 def renderElement(tag, **kw):




More information about the Zope3-Checkins mailing list