[Zope3-checkins] CVS: Zope3/src/zope/schema - __init__.py:1.10 _bootstrapfields.py:1.11 _field.py:1.9 interfaces.py:1.9

Fred L. Drake, Jr. fred@zope.com
Mon, 14 Apr 2003 14:21:37 -0400


Update of /cvs-repository/Zope3/src/zope/schema
In directory cvs.zope.org:/tmp/cvs-serv28909/src/zope/schema

Modified Files:
	__init__.py _bootstrapfields.py _field.py interfaces.py 
Log Message:
Rename IValueSet to IEnumerated, and ValueSet to Enumerated.
Treat these more like mixins than like directly useful things.


=== Zope3/src/zope/schema/__init__.py 1.9 => 1.10 ===
--- Zope3/src/zope/schema/__init__.py:1.9	Mon Apr 14 12:13:42 2003
+++ Zope3/src/zope/schema/__init__.py	Mon Apr 14 14:21:36 2003
@@ -17,7 +17,8 @@
 """
 
 from zope.schema._field import Field, Container, Iterable, Orderable
-from zope.schema._field import MinMaxLen, ValueSet, Sequence, Bytes, BytesLine
+from zope.schema._field import MinMaxLen, Enumerated, Sequence
+from zope.schema._field import Bytes, BytesLine
 from zope.schema._field import Text, TextLine, Bool, Int, Float, Tuple, List
 from zope.schema._field import Password, Dict, Datetime, SourceText
 from zope.schema._field import EnumeratedTextLine, EnumeratedInt
@@ -25,3 +26,6 @@
 from zope.schema._schema import getFields, getFieldsInOrder
 from zope.schema._schema import getFieldNames, getFieldNamesInOrder
 from zope.schema.accessors import accessors
+
+# XXX backward compatibility; to be removed within a week
+ValueSet = Enumerated


=== Zope3/src/zope/schema/_bootstrapfields.py 1.10 => 1.11 ===
--- Zope3/src/zope/schema/_bootstrapfields.py:1.10	Mon Apr 14 12:13:42 2003
+++ Zope3/src/zope/schema/_bootstrapfields.py	Mon Apr 14 14:21:36 2003
@@ -218,13 +218,13 @@
             raise ValidationError(errornames.TooLong, value, self.max_length)
 
 
-class ValueSet(Field):
+class Enumerated(Field):
 
     def __init__(self, allowed_values=None, default=None, **kw):
         # Set allowed_values to None so that we can validate if
         # one of the super methods invoke validation.
         self.__dict__['allowed_values'] = None
-        super(ValueSet, self).__init__(**kw)
+        super(Enumerated, self).__init__(**kw)
         if allowed_values is not None:
             self.allowed_values = allowed_values
 
@@ -254,14 +254,13 @@
     allowed_values = ValidatedProperty('allowed_values', allowed_values)
 
     def _validate(self, value):
-        super(ValueSet, self)._validate(value)
+        super(Enumerated, self)._validate(value)
         if self.allowed_values:
             if not value in self.allowed_values:
                 raise ValidationError(errornames.InvalidValue, value,
                                       self.allowed_values)
 
-
-class Text(MinMaxLen, ValueSet):
+class Text(MinMaxLen, Enumerated, Field):
     """A field containing text used for human discourse."""
     _type = unicode
 
@@ -280,7 +279,7 @@
     def constraint(self, value):
         return '\n' not in value and '\r' not in value
 
-class EnumeratedTextLine(ValueSet, TextLine):
+class EnumeratedTextLine(Enumerated, TextLine):
     """TextLine with a value from a list of allowed values."""
 
 class Password(TextLine):
@@ -290,7 +289,7 @@
     """A field representing a Bool."""
     _type = type(True)
 
-class Int(ValueSet, Orderable):
+class Int(Enumerated, Orderable, Field):
     """A field representing an Integer."""
     _type = int, long
 
@@ -303,5 +302,5 @@
                           DeprecationWarning, stacklevel=2)
         super(Int, self).__init__(*args, **kw)
 
-class EnumeratedInt(ValueSet, Int):
+class EnumeratedInt(Enumerated, Int):
     """A field representing one of a selected set of Integers."""


=== Zope3/src/zope/schema/_field.py 1.8 => 1.9 ===
--- Zope3/src/zope/schema/_field.py:1.8	Mon Apr 14 12:13:42 2003
+++ Zope3/src/zope/schema/_field.py	Mon Apr 14 14:21:36 2003
@@ -24,7 +24,7 @@
 from zope.schema.errornames import WrongContainedType
 
 from zope.schema.interfaces import IField, IContainer, IIterable, IOrderable
-from zope.schema.interfaces import IMinMaxLen, IValueSet, IText, ITextLine
+from zope.schema.interfaces import IMinMaxLen, IEnumerated, IText, ITextLine
 from zope.schema.interfaces import ISourceText
 from zope.schema.interfaces import IBool, IInt, IBytes, IBytesLine, IFloat
 from zope.schema.interfaces import IDatetime, ISequence, ITuple, IList, IDict
@@ -33,7 +33,7 @@
 from zope.schema.interfaces import IEnumeratedInt, IEnumeratedFloat
 
 from zope.schema._bootstrapfields import Field, Container, Iterable, Orderable
-from zope.schema._bootstrapfields import MinMaxLen, ValueSet
+from zope.schema._bootstrapfields import MinMaxLen, Enumerated
 from zope.schema._bootstrapfields import Text, TextLine, Bool, Int, Password
 from zope.schema._bootstrapfields import EnumeratedTextLine, EnumeratedInt
 from zope.schema.fieldproperty import FieldProperty
@@ -63,7 +63,7 @@
     __implements__ = ISourceText
     _type = unicode
 
-class Bytes(MinMaxLen, ValueSet):
+class Bytes(MinMaxLen, Enumerated, Field):
     __doc__ = IBytes.__doc__
     __implements__ = IBytes
 
@@ -79,7 +79,7 @@
         return '\n' not in value
 
 
-class Float(ValueSet, Orderable):
+class Float(Enumerated, Orderable, Field):
     __doc__ = IFloat.__doc__
     __implements__ = IFloat
     _type = float
@@ -93,11 +93,11 @@
                           DeprecationWarning, stacklevel=2)
         super(Float, self).__init__(*args, **kw)
 
-class EnumeratedFloat(ValueSet, Float):
+class EnumeratedFloat(Enumerated, Float):
     __doc__ = IEnumeratedFloat.__doc__
     __implements__ = IEnumeratedFloat
 
-class Datetime(ValueSet, Orderable):
+class Datetime(Enumerated, Orderable, Field):
     __doc__ = IDatetime.__doc__
     __implements__ = IDatetime
     _type = datetime
@@ -111,7 +111,7 @@
                           DeprecationWarning, stacklevel=2)
         super(Datetime, self).__init__(*args, **kw)
 
-class EnumeratedDatetime(ValueSet, Datetime):
+class EnumeratedDatetime(Enumerated, Datetime):
     __doc__ = IEnumeratedDatetime.__doc__
     __implements__ = IEnumeratedDatetime
 


=== Zope3/src/zope/schema/interfaces.py 1.8 => 1.9 ===
--- Zope3/src/zope/schema/interfaces.py:1.8	Mon Apr 14 12:13:42 2003
+++ Zope3/src/zope/schema/interfaces.py	Mon Apr 14 14:21:36 2003
@@ -248,7 +248,7 @@
         min=0, # needs to be a positive number
         default=None)
 
-class IValueSet(IField):
+class IEnumerated(IField):
     u"""Field whose value is contained in a predefined set"""
 
     allowed_values = Container(
@@ -259,11 +259,13 @@
         restictions.""",
         required=False)
 
+IValueSet = IEnumerated
+
 class IBool(IField):
     u"""a Boolean Field."""
 
-class IBytes(IMinMaxLen, IValueSet, IIterable):
-    # XXX IValueSet will be removed in the future.
+class IBytes(IMinMaxLen, IEnumerated, IIterable):
+    # XXX IEnumerated will be removed in the future.
     u"""a Field containing a byte string (like the python str).
 
     The value might be contrained to be with length limits.
@@ -272,8 +274,8 @@
 class IBytesLine(IBytes):
     u"""a Field containing a byte string without newlines."""
 
-class IText(IMinMaxLen, IValueSet, IIterable):
-    # XXX IValueSet doesn't make sense for multi-line strings, so will
+class IText(IMinMaxLen, IEnumerated, IIterable):
+    # XXX IEnumerated doesn't make sense for multi-line strings, so will
     # be removed in the future.
     u"""a Field containing a unicode string."""
 
@@ -283,7 +285,7 @@
 class ITextLine(IText):
     u"""a Field containing a unicode string without newlines."""
 
-class IEnumeratedTextLine(ITextLine, IValueSet):
+class IEnumeratedTextLine(ITextLine, IEnumerated):
     u"""a Field containing a unicode string without newlines.
 
     The value may be constrained to an element of a specified list.
@@ -292,34 +294,34 @@
 class IPassword(ITextLine):
     u"""a Field containing a unicode string without newlines that is a password."""
 
-class IInt(IMinMax, IValueSet):
-    # XXX IValueSet will be removed; use IEnumeratedInt instead if you
-    # need the IValueSet interface.
+class IInt(IMinMax, IEnumerated):
+    # XXX IEnumerated will be removed; use IEnumeratedInt instead if you
+    # need the IEnumerated interface.
     u"""a Field containing an Integer Value."""
 
-class IEnumeratedInt(IInt, IValueSet):
+class IEnumeratedInt(IInt, IEnumerated):
     u"""a Field containing an Integer Value.
 
     The value may be constrained to an element of a specified list.
     """
 
-class IFloat(IMinMax, IValueSet):
-    # XXX IValueSet will be removed; use IEnumeratedFloat instead if you
-    # need the IValueSet interface.
+class IFloat(IMinMax, IEnumerated):
+    # XXX IEnumerated will be removed; use IEnumeratedFloat instead if you
+    # need the IEnumerated interface.
     u"""a Field containing a Float."""
 
-class IEnumeratedFloat(IFloat, IValueSet):
+class IEnumeratedFloat(IFloat, IEnumerated):
     u"""a Field containing a Float.
 
     The value may be constrained to an element of a specified list.
     """
 
-class IDatetime(IMinMax, IValueSet):
-    # XXX IValueSet will be removed; use IEnumeratedDatetime instead
-    # if you need the IValueSet interface.
+class IDatetime(IMinMax, IEnumerated):
+    # XXX IEnumerated will be removed; use IEnumeratedDatetime instead
+    # if you need the IEnumerated interface.
     u"""a Field containing a DateTime."""
 
-class IEnumeratedDatetime(IDatetime, IValueSet):
+class IEnumeratedDatetime(IDatetime, IEnumerated):
     u"""a Field containing a DateTime.
 
     The value may be constrained to an element of a specified list.