[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - vocabularywidget.py:1.13
Fred L. Drake, Jr.
fred@zope.com
Thu, 29 May 2003 15:33:51 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv9129
Modified Files:
vocabularywidget.py
Log Message:
Change of behavior:
- always set the query index in the form if a search has been
performed, otherwise use None as the local value so we'll know that
no search is active
=== Zope3/src/zope/app/browser/form/vocabularywidget.py 1.12 => 1.13 ===
--- Zope3/src/zope/app/browser/form/vocabularywidget.py:1.12 Thu May 29 15:05:50 2003
+++ Zope3/src/zope/app/browser/form/vocabularywidget.py Thu May 29 15:33:51 2003
@@ -502,10 +502,10 @@
try:
self.query_index = int(get(self.query_index_name, 0))
except ValueError:
- self.query_index = 0
+ self.query_index = None
else:
if self.query_index < 0:
- self.query_index = 0
+ self.query_index = None
QS = get(self.query_selections_name, [])
if not isinstance(QS, list):
QS = [QS]
@@ -514,7 +514,7 @@
try:
term = self.vocabulary.getTermByToken(token)
except LookupError:
- raise ValidationError
+ raise ValidationError, "token %r not in vocabulary" % token
else:
self.query_selections.append(term.value)
@@ -523,7 +523,10 @@
return ""
def getResults(self):
- return self.vocabulary
+ if self.query_index is not None:
+ return self.vocabulary
+ else:
+ return None
def renderQueryResults(self, results, value):
# display query results batch
@@ -552,17 +555,16 @@
except StopIteration:
have_more = False
self.query_selections = QS
- L = ["<div class='results'>\n",
+ return ''.join(
+ ["<div class='results'>\n",
self.makeSelectionList(items, self.query_selections_name),
"\n",
self.renderAction(ADD_DONE), "\n",
self.renderAction(ADD_MORE, not have_more), "\n",
- self.renderAction(MORE, not have_more), "\n"]
- if qi:
- L.append("<input type='hidden' name='%s' value='%d' />\n"
- % (self.query_index_name, qi))
- L.append("</div>")
- return ''.join(L)
+ self.renderAction(MORE, not have_more), "\n"
+ "<input type='hidden' name='%s' value='%d' />\n"
+ % (self.query_index_name, qi),
+ "</div>"])
def performQueryAction(self, value):
if self.action == ADD_DONE: