I'm trying to build a widget that allows for auto-complete of items in a
vocabulary, but also allows additional (string) values to be added. To
understand how that works, I am digging into z3c.formwidget.query, and
it looks to me like it's making incorrect assumptions about its own
In its interfaces.py, we have:
from zope.schema.interfaces import ISource, IVocabularyTokenized
class IQuerySource(ISource, IVocabularyTokenized):
"""Return values that match query."""
so, an IQuerySource is an ISource, which is:
"""Return whether the value is available in this source
and also an IVocabularyTokenized, which is:
"""Return the ITerm object for the term 'value'.
If 'value' is not a valid term, this method raises LookupError.
# BBB vocabularies are pending deprecation, hopefully in 3.3
"""Return an iterator which provides the terms from the
"""Return the number of valid terms, or sys.maxint."""
class IVocabulary(IIterableVocabulary, IBaseVocabulary):
"""Vocabulary which is iterable."""
"""Return an ITokenizedTerm for the passed-in token.
If `token` is not represented in the vocabulary, `LookupError`
First of all, it seems strange then that IQuerySource should explicitly
need to say it's derived from ISource since IVocabularyTokenized already
However, more importantly, in the README.txt of z3c.formwidget.query we
... def getTermByValue(self, value):
... return self.vocabulary.by_value[value]
and similarly, in widget.py:
filter(lambda value: value and value not in values,
If I'm not reading this wrong, it seems to me that z3c.formwidget.query
is using getTermByValue() (which I can't find anywhere else) instead of
getTermByToken() as defined by IVocabularyTokenized.
Is this correct?
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
Zope-Dev maillist - Zope-Dev@zope.org
** No cross posts or HTML encoding! **
(Related lists -