[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - vocabularywidget.py:1.16
Fred L. Drake, Jr.
fred@zope.com
Thu, 29 May 2003 18:25:20 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv1535
Modified Files:
vocabularywidget.py
Log Message:
- raise the right exception for invalid form data
- multi-select fields are always set (can be an empty list)
=== Zope3/src/zope/app/browser/form/vocabularywidget.py 1.15 => 1.16 ===
--- Zope3/src/zope/app/browser/form/vocabularywidget.py:1.15 Thu May 29 17:17:38 2003
+++ Zope3/src/zope/app/browser/form/vocabularywidget.py Thu May 29 18:25:20 2003
@@ -25,11 +25,12 @@
from zope.app.browser.form import widget
from zope.app.i18n import ZopeMessageIDFactory as _
from zope.app.interfaces.browser.form import IVocabularyQueryView
+from zope.app.interfaces.form import WidgetInputError
from zope.publisher.browser import BrowserView
from zope.component import getView
from zope.schema.interfaces import IIterableVocabulary, IVocabularyQuery
from zope.schema.interfaces import IIterableVocabularyQuery
-from zope.schema.interfaces import IVocabularyTokenized, ValidationError
+from zope.schema.interfaces import IVocabularyTokenized
# These widget factories delegate to the vocabulary on the field.
@@ -379,6 +380,9 @@
class VocabularyMultiEditWidget(VocabularyEditWidgetBase):
"""Vocabulary-backed widget supporting multiple selections."""
+ def haveData(self):
+ return True
+
def renderItems(self, value):
if value == self._missing:
values = ()
@@ -516,7 +520,11 @@
try:
term = self.vocabulary.getTermByToken(token)
except LookupError:
- raise ValidationError, "token %r not in vocabulary" % token
+ # XXX unsure what to pass to exception constructor
+ raise WidgetInputError(
+ "(query view for %s)" % self.context,
+ "(query view for %s)" % self.context,
+ "token %r not in vocabulary" % token)
else:
self.query_selections.append(term.value)