[Zope3-checkins] CVS: Zope3/src/zope/schema - interfaces.py:1.40
vocabulary.py:1.20
Stephan Richter
srichter at cosmos.phy.tufts.edu
Sat Feb 14 18:36:00 EST 2004
Update of /cvs-repository/Zope3/src/zope/schema
In directory cvs.zope.org:/tmp/cvs-serv16460/src/zope/schema
Modified Files:
interfaces.py vocabulary.py
Log Message:
- Added __contains__ to the IBaseVocabulary, since it is required by the
VocabularyWidget and the SimpleVocabulary implemented it as well. Removed
the places where I had explicitly allowed __contains__ before.
- Updated doc strings to tell the reader to which interface the
SimpleVocabulary methods belong.
=== Zope3/src/zope/schema/interfaces.py 1.39 => 1.40 ===
--- Zope3/src/zope/schema/interfaces.py:1.39 Thu Jan 22 11:31:27 2004
+++ Zope3/src/zope/schema/interfaces.py Sat Feb 14 18:35:59 2004
@@ -457,6 +457,9 @@
vocabularies which are intrinsically ordered).
"""
+ def __contains__(value):
+ """Returns True if the value is available in this vocabulary."""
+
def getQuery():
"""Return an IVocabularyQuery object for this vocabulary.
=== Zope3/src/zope/schema/vocabulary.py 1.19 => 1.20 ===
--- Zope3/src/zope/schema/vocabulary.py:1.19 Wed Jan 28 18:07:42 2004
+++ Zope3/src/zope/schema/vocabulary.py Sat Feb 14 18:35:59 2004
@@ -11,9 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""Vocabulary support for schema.
-"""Vocabulary support for schema."""
-
+$Id$
+"""
import copy
from zope.interface.declarations import directlyProvides, implements
@@ -159,7 +160,7 @@
# simple vocabularies performing enumerated-like tasks
-class SimpleTerm:
+class SimpleTerm(object):
"""Simple tokenized term used by SimpleVocabulary."""
implements(ITokenizedTerm)
@@ -241,27 +242,33 @@
createTerm = classmethod(createTerm)
def __contains__(self, value):
+ """See zope.schema.interfaces.IBaseVocabulary"""
return value in self.by_value
def getQuery(self):
+ """See zope.schema.interfaces.IBaseVocabulary"""
return None
def getTerm(self, value):
+ """See zope.schema.interfaces.IBaseVocabulary"""
try:
return self.by_value[value]
except KeyError:
raise LookupError(value)
def getTermByToken(self, token):
+ """See zope.schema.interfaces.IVocabularyTokenized"""
try:
return self.by_token[token]
except KeyError:
raise LookupError(token)
def __iter__(self):
+ """See zope.schema.interfaces.IIterableVocabulary"""
return iter(self._terms)
def __len__(self):
+ """See zope.schema.interfaces.IIterableVocabulary"""
return len(self.by_value)
# registry code
@@ -283,6 +290,7 @@
self._map = {}
def get(self, object, name):
+ """See zope.schema.interfaces.IVocabularyRegistry"""
try:
vtype = self._map[name]
except KeyError:
More information about the Zope3-Checkins
mailing list