[Zope3-dev] question about IVocabulary
Garrett Smith
garrett@mojave-corp.com
Tue, 15 Jul 2003 11:26:45 -0500
The example provided in vocabularies.txt does not implement two methods
that are a part of IVocabulary:
getQuery() and getTerm(value)
Here's the sample code:
class StateVocabulary(object):
# Actually, we need only one of these. Using __slots__ will make
# these objects small. We could also use __new__ to make this a
# singleton.
__slots__ =3D ()
implements(IVocabulary)
def __init__(self):
pass
def __contains__(self, value):
return value in _states
def __iter__(self):
return _states.itervalues()
def __len__(self):
return len(_states)
Unless there's some serious magic going on, an instance of this class
will fail verifyObject.
More importantly, should getQuery be in IVocabluary? I would have
expected something like this to be in an IQueriableVocabulary mixin.
-- Garrett