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

Gary Poster gary@zope.com
Tue, 3 Jun 2003 11:14:26 -0400


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

Modified Files:
	vocabularywidget.py 
Log Message:
add back multi widget default of []



=== Zope3/src/zope/app/browser/form/vocabularywidget.py 1.28 => 1.29 ===
--- Zope3/src/zope/app/browser/form/vocabularywidget.py:1.28	Tue Jun  3 10:16:11 2003
+++ Zope3/src/zope/app/browser/form/vocabularywidget.py	Tue Jun  3 11:14:26 2003
@@ -246,6 +246,14 @@
             return self.convertTokensToValues(tokens)
         return []
 
+    def _getDefault(self):
+        # Return the default value for this widget;
+        # may be overridden by subclasses.
+        val = self.context.default
+        if val is None:
+            val = []
+        return val
+
 class VocabularyDisplayWidget(SingleDataHelper, VocabularyWidgetBase):
     """Simple single-selection display that can be used in many cases."""
 
@@ -263,22 +271,22 @@
     tag = 'ol'
 
     def render(self, value):
-        if value == self._missing:
-            return widget.renderElement('span',
+        if value:
+            rendered_items = self.renderItems(value)
+            return widget.renderElement(self.getValue('tag'),
                                         type=self.getValue('type'),
                                         name=self.name,
                                         id=self.name,
                                         cssClass=self.getValue('cssClass'),
-                                        contents=_("(no values)"),
+                                        contents="\n".join(rendered_items),
                                         extra=self.getValue('extra'))
         else:
-            rendered_items = self.renderItems(value)
-            return widget.renderElement(self.getValue('tag'),
+            return widget.renderElement('span',
                                         type=self.getValue('type'),
                                         name=self.name,
                                         id=self.name,
                                         cssClass=self.getValue('cssClass'),
-                                        contents="\n".join(rendered_items),
+                                        contents=_("(no values)"),
                                         extra=self.getValue('extra'))
 
     def renderItems(self, value):