[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - configure.zcml:1.9 vocabularywidget.py:1.5
Fred L. Drake, Jr.
fred@zope.com
Wed, 21 May 2003 20:40:03 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv24126
Modified Files:
configure.zcml vocabularywidget.py
Log Message:
Clean up the query view helpers for simple iterable vocabularies so they
work more reasonably for both single- and multi-selection vocabulary fields.
=== Zope3/src/zope/app/browser/form/configure.zcml 1.8 => 1.9 ===
--- Zope3/src/zope/app/browser/form/configure.zcml:1.8 Wed May 21 17:11:23 2003
+++ Zope3/src/zope/app/browser/form/configure.zcml Wed May 21 20:39:33 2003
@@ -145,8 +145,17 @@
type="zope.publisher.interfaces.browser.IBrowserPresentation"
allowed_interface="zope.app.interfaces.browser.form.IVocabularyQueryView"
for="zope.schema.interfaces.IIterableVocabularyQuery"
- name="widget-query-multi-helper"
+ name="widget-query-helper"
factory=".vocabularywidget.IterableVocabularyQueryView"
+ />
+
+ <view
+ permission="zope.Public"
+ type="zope.publisher.interfaces.browser.IBrowserPresentation"
+ allowed_interface="zope.app.interfaces.browser.form.IVocabularyQueryView"
+ for="zope.schema.interfaces.IIterableVocabularyQuery"
+ name="widget-query-multi-helper"
+ factory=".vocabularywidget.IterableVocabularyQueryMultiView"
/>
<!-- Default simple display view -->
=== Zope3/src/zope/app/browser/form/vocabularywidget.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/form/vocabularywidget.py:1.4 Wed May 21 20:17:40 2003
+++ Zope3/src/zope/app/browser/form/vocabularywidget.py Wed May 21 20:39:33 2003
@@ -433,7 +433,7 @@
return msgid
-class IterableVocabularyQueryView(VocabularyQueryViewBase):
+class IterableVocabularyQueryViewBase(VocabularyQueryViewBase):
"""Query view for IIterableVocabulary objects without more
specific query views.
@@ -509,8 +509,8 @@
have_more = False
self.query_selections = QS
L = ["<div class='results'>\n",
- self.mkselectionlist("checkbox",
- items, self.query_selections_name), "\n",
+ self.makeSelectionList(items, self.query_selections_name),
+ "\n",
self._mkbutton(ADD_DONE), "\n",
self._mkbutton(ADD_MORE, not have_more), "\n",
self._mkbutton(MORE, not have_more), "\n"]
@@ -556,3 +556,17 @@
if item not in value and item in self.context.vocabulary:
value.append(item)
return value
+
+class IterableVocabularyQueryView(IterableVocabularyQueryViewBase):
+
+ def makeSelectionList(self, items, name):
+ return self.mkselectionlist("radio", items, name)
+
+ def renderQueryResults(self, results, value):
+ return IterableVocabularyQueryViewBase.renderQueryResults(
+ self, results, [value])
+
+class IterableVocabularyQueryMultiView(IterableVocabularyQueryViewBase):
+
+ def makeSelectionList(self, items, name):
+ return self.mkselectionlist("checkbox", items, name)