[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form -
vocabularywidget.py:1.59
Fred L. Drake, Jr.
fred at zope.com
Mon Sep 29 16:13:43 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv18259
Modified Files:
vocabularywidget.py
Log Message:
- refactor "no value" messages to match behavior for other form fields
(if there's no value, generate blank space, not a message)
- update tests to match
=== Zope3/src/zope/app/browser/form/vocabularywidget.py 1.58 => 1.59 ===
--- Zope3/src/zope/app/browser/form/vocabularywidget.py:1.58 Thu Sep 25 17:43:12 2003
+++ Zope3/src/zope/app/browser/form/vocabularywidget.py Mon Sep 29 16:13:12 2003
@@ -265,9 +265,20 @@
raise NotImplementedError(
"vocabulary-based widgets don't use the _unconvert() method")
-class SingleDataHelper(object):
- _msg_no_value = message(_("vocabulary-no-value"), "(no value)")
+
+
+_msg_missing_single_value_display = message(
+ _("vocabulary-missing-single-value-for-display"), "")
+_msg_missing_multiple_value_display = message(
+ _("vocabulary-missing-multiple-value-for-display"), "")
+
+_msg_missing_single_value_edit = message(
+ _("vocabulary-missing-single-value-for-edit"), "(no value)")
+_msg_missing_multiple_value_edit = message(
+ _("vocabulary-missing-multiple-value-for-edit"), "(no values)")
+
+class SingleDataHelper(object):
def _compute_data(self):
token = self.request.form.get(self.name)
@@ -297,6 +308,8 @@
class VocabularyDisplayWidget(SingleDataHelper, VocabularyWidgetBase):
"""Simple single-selection display that can be used in many cases."""
+ _msg_no_value = _msg_missing_single_value_display
+
def render(self, value):
if value is None:
return self.translate(self._msg_no_value)
@@ -324,13 +337,7 @@
contents="\n".join(rendered_items),
extra=self.getValue('extra'))
else:
- return widget.renderElement('span',
- type=self.getValue('type'),
- name=self.name,
- id=self.name,
- cssClass=self.getValue('cssClass'),
- contents=_("(no values)"),
- extra=self.getValue('extra'))
+ return self.translate(_msg_missing_multiple_value_display)
def renderItems(self, value):
L = []
@@ -501,6 +508,8 @@
propertyNames = VocabularyEditWidgetBase.propertyNames + ['firstItem']
firstItem = False
+ _msg_no_value = _msg_missing_single_value_edit
+
def renderValue(self, value):
rendered_items = self.renderItems(value)
contents = "\n%s\n" % "\n".join(rendered_items)
@@ -539,6 +548,8 @@
class VocabularyMultiEditWidget(MultiDataHelper, VocabularyEditWidgetBase):
"""Vocabulary-backed widget supporting multiple selections."""
+
+ _msg_no_value = _msg_missing_multiple_value_edit
def renderItems(self, value):
if value == self.context.missing_value:
More information about the Zope3-Checkins
mailing list