[Zope-Checkins] CVS: Zope3/lib/python/Schema - ErrorNames.py:1.4 IField.py:1.3 Validator.py:1.2 _Field.py:1.5 _Schema.py:1.5
Martijn Faassen
m.faassen@vet.uu.nl
Sun, 14 Jul 2002 13:30:33 -0400
Update of /cvs-repository/Zope3/lib/python/Schema
In directory cvs.zope.org:/tmp/cvs-serv17270
Modified Files:
ErrorNames.py IField.py Validator.py _Field.py _Schema.py
Log Message:
Renamed String, Integer, Boolean and Dictionary back to the more Pythonic
Str, Int, Bool and Dict, which map the type constructors as of Python 2.2
(and 2.3 for Bool).
=== Zope3/lib/python/Schema/ErrorNames.py 1.3 => 1.4 ===
RequiredMissing ='RequiredMissing'
-RequiredEmptyString = 'RequiredEmptyString'
+RequiredEmptyStr = 'RequiredEmptyString'
TooBig = 'TooBig'
=== Zope3/lib/python/Schema/IField.py 1.2 => 1.3 ===
class IField(Interface):
"""All fields conform to this schema. Note that the interpretation
of 'required' is up to each field by itself. For some fields, such as
- IBoolean, requiredness settings may make no difference.
+ IBool, requiredness settings may make no difference.
"""
- title = Field.String(
+ title = Field.Str(
title="Title",
description="Title.",
default=""
)
- description = Field.String(
+ description = Field.Str(
title="Description",
description="Description.",
default="",
required=0)
- readonly = Field.Boolean(
+ readonly = Field.Bool(
title="Read Only",
description="Read-only.",
default=0)
- required = Field.Boolean(
+ required = Field.Bool(
title="Required",
description="Required.",
default=1)
@@ -62,24 +62,24 @@
-class IBoolean(ISingleValueField):
- """Describes the footprint of a Boolean variable."""
+class IBool(ISingleValueField):
+ """Describes the footprint of a Bool variable."""
- default = Field.Boolean(
+ default = Field.Bool(
title="Default",
description="Default.",
default=0)
-class IString(ISingleValueField):
- """Describes the footprint of a String variable."""
+class IStr(ISingleValueField):
+ """Describes the footprint of a Str variable."""
- default = Field.String(
+ default = Field.Str(
title="Default",
description="Default.",
default="")
- whitespace = Field.String(
+ whitespace = Field.Str(
title="Whitespace",
description="preserve: whitespace is preserved."
"replace: all occurences of tab, line feed and "
@@ -91,7 +91,7 @@
allowed_values=("preserve", "replace", "collapse", "strip"),
default="strip")
- min_length = Field.Integer(
+ min_length = Field.Int(
title="Minimum length",
description=("Value after whitespace processing cannot have less than "
"min_length characters. If min_length is None, there is "
@@ -100,7 +100,7 @@
min=0, # needs to be a positive number
default=0)
- max_length = Field.Integer(
+ max_length = Field.Int(
title="Maximum length",
description=("Value after whitespace processing cannot have greater "
"or equal than max_length characters. If max_length is "
@@ -110,22 +110,22 @@
default=None)
-class IInteger(ISingleValueField):
- """Describes the footprint of an Integer variable."""
+class IInt(ISingleValueField):
+ """Describes the footprint of an Int variable."""
- default = Field.Integer(
+ default = Field.Int(
title="Default",
description="Default.",
default=0)
- min = Field.Integer(
+ min = Field.Int(
title="Minimum",
description="The minimal numerical value accepted. If min is None, "
"there is no minimum.",
required=0,
default=0)
- max = Field.Integer(
+ max = Field.Int(
title="Maximum",
description="The masximal numerical value accepted. If min is None, "
"there is no minimum.",
@@ -155,7 +155,7 @@
required=0,
default=None)
- decimals = Field.Integer(
+ decimals = Field.Int(
title="Decimal Places",
description="Defines the amount of decimal places the floating point "
"can have. This value is also know as precision. If the "
@@ -175,7 +175,7 @@
required=0,
default=())
- min_values = Field.Integer(
+ min_values = Field.Int(
title="Minimum amount of values",
description="The minimum amount of values in the list. If min_values "
"is None, there is no minimum.",
@@ -183,7 +183,7 @@
required=0,
default=0)
- max_values = Field.Integer(
+ max_values = Field.Int(
title="Maximum amount of values",
description="The maximum amount of values in the list. If max_values "
"is None, there is no maximum.",
@@ -210,10 +210,10 @@
default=[])
-class IDictionary(IMultipleValueField):
- """Describes the footprint of a Dictionary variable."""
+class IDict(IMultipleValueField):
+ """Describes the footprint of a Dict variable."""
- default = Field.Dictionary(
+ default = Field.Dict(
title="Default",
description="Default.",
default={})
=== Zope3/lib/python/Schema/Validator.py 1.1 => 1.2 ===
raise StopValidation
return value
-class StringRequiredValidator(Validator):
- """Empty Strings are not acceptable for a required field."""
+class StrRequiredValidator(Validator):
+ """Empty Str are not acceptable for a required field."""
def validate(self, value):
'See Schema.IValidator.IValidator'
if self.field.required and value == '':
- raise ValidationError, ErrorNames.RequiredEmptyString
+ raise ValidationError, ErrorNames.RequiredEmptyStr
return value
class MinimumLengthValidator(Validator):
@@ -217,18 +217,18 @@
"""Validator for Single Value Fields"""
validators = ContainerValidator.validators + [AllowedValuesValidator]
-class StringValidator(SingleValueValidator):
- """Completely validates a String Field."""
- validators = SingleValueValidator.validators + [StringRequiredValidator,
+class StrValidator(SingleValueValidator):
+ """Completely validates a Str Field."""
+ validators = SingleValueValidator.validators + [StrRequiredValidator,
WhitespaceValidator,
MinimumLengthValidator,
MaximumLengthValidator]
-class BooleanValidator(SingleValueValidator):
- """Completely validates a Boolean Field."""
+class BoolValidator(SingleValueValidator):
+ """Completely validates a Bool Field."""
-class IntegerValidator(SingleValueValidator):
- """Completely validates a Integer Field."""
+class IntValidator(SingleValueValidator):
+ """Completely validates a Int Field."""
validators = SingleValueValidator.validators + [MinimumValueValidator,
MaximumValueValidator]
@@ -250,8 +250,8 @@
class ListValidator(TupleValidator):
"""Completely validates a List Field."""
-class DictionaryValidator(MultiValueValidator):
- """Completely validates a Dictionary Field."""
+class DictValidator(MultiValueValidator):
+ """Completely validates a Dict Field."""
validators = ContainerValidator.validators + [
DictKeyTypeValidator, DictValueTypeValidator,
MinimumAmountOfItemsValidator, MaximumAmountOfItemsValidator]
=== Zope3/lib/python/Schema/_Field.py 1.4 => 1.5 ===
"""A field that contains only one value."""
allowed_values = []
-class String(SingleValueField):
- """A field representing a String."""
+class Str(SingleValueField):
+ """A field representing a Str."""
type = str
min_length = None
max_length = None
whitespaces = "preserve"
-class Boolean(SingleValueField):
- """A field representing a Boolean."""
+class Bool(SingleValueField):
+ """A field representing a Bool."""
type = type(not 1)
-class Integer(SingleValueField):
+class Int(SingleValueField):
"""A field representing a Integer."""
type = int
min = max = None
@@ -78,8 +78,8 @@
value_types = None
min_values = max_values = None
-class Dictionary(Field):
- """A field representing a Dictionary."""
+class Dict(Field):
+ """A field representing a Dict."""
type = dict
min_values = max_values = None
key_types = value_types = None
=== Zope3/lib/python/Schema/_Schema.py 1.4 => 1.5 ===
implements(Field, IField, 0)
Field.validator = Validator.RequiredValidator
- from IField import IBoolean
- from _Field import Boolean
- implements(Boolean, IBoolean, 0)
- Boolean.validator = Validator.BooleanValidator
-
- from IField import IString
- from _Field import String
- implements(String, IString, 0)
- String.validator = Validator.StringValidator
-
- from IField import IInteger
- from _Field import Integer
- implements(Integer, IInteger, 0)
- Integer.validator = Validator.IntegerValidator
+ from IField import IBool
+ from _Field import Bool
+ implements(Bool, IBool, 0)
+ Bool.validator = Validator.BoolValidator
+
+ from IField import IStr
+ from _Field import Str
+ implements(Str, IStr, 0)
+ Str.validator = Validator.StrValidator
+
+ from IField import IInt
+ from _Field import Int
+ implements(Int, IInt, 0)
+ Int.validator = Validator.IntValidator
from IField import IFloat
from _Field import Float
@@ -92,10 +92,10 @@
implements(List, IList, 0)
List.validator = Validator.ListValidator
- from IField import IDictionary
- from _Field import Dictionary
- implements(Dictionary, IDictionary, 0)
- Dictionary.validator = Validator.DictionaryValidator
+ from IField import IDict
+ from _Field import Dict
+ implements(Dict, IDict, 0)
+ Dict.validator = Validator.DictValidator
wire()