[Zope3-checkins] CVS: Zope3/src/zope/schema - __init__.py:1.4 _bootstrapfields.py:1.3 _schema.py:1.3 interfaces.py:1.4
Jim Fulton
jim@zope.com
Thu, 9 Jan 2003 09:13:51 -0500
Update of /cvs-repository/Zope3/src/zope/schema
In directory cvs.zope.org:/tmp/cvs-serv14386/src/zope/schema
Modified Files:
__init__.py _bootstrapfields.py _schema.py interfaces.py
Log Message:
- Got rid of (essentially) unused validateMapping, validateMappingAll,
ValidationErrorsAll and ConversionErrorsAll.
- Renamed zope.app.interfaces.forms to zope.app.interfaces.form
- Changed the way form input errors are handled. Now, *only*
validation errors and widget input errors are caught and displayed
on forms. These errors are about data entry problems. For these, it
never makes sense to show a traceback.
For Python programming errors, we want tracebacks, so it's important
to handle them differently, but letting the propigate and get logged
by the error reporting service.
This required updating the widget code to be more careful about
errors raised.
=== Zope3/src/zope/schema/__init__.py 1.3 => 1.4 ===
--- Zope3/src/zope/schema/__init__.py:1.3 Mon Dec 30 13:42:29 2002
+++ Zope3/src/zope/schema/__init__.py Thu Jan 9 09:13:18 2003
@@ -20,5 +20,4 @@
from zope.schema._field import MinMaxLen, ValueSet, Sequence, Bytes, BytesLine
from zope.schema._field import Text, TextLine, Bool, Int, Float, Tuple, List
from zope.schema._field import Dict, Datetime
-from zope.schema._schema import validateMapping, validateMappingAll
from zope.schema._schema import getFields, getFieldsInOrder
=== Zope3/src/zope/schema/_bootstrapfields.py 1.2 => 1.3 ===
--- Zope3/src/zope/schema/_bootstrapfields.py:1.2 Wed Dec 25 09:15:20 2002
+++ Zope3/src/zope/schema/_bootstrapfields.py Thu Jan 9 09:13:18 2003
@@ -20,8 +20,8 @@
from zope.interface.implements import visitImplements
from zope.schema.interfaces import StopValidation, ValidationError
-from zope.schema import errornames
from zope.schema._schema import getFields
+from zope.schema import errornames
class ValidatedProperty:
@@ -272,3 +272,4 @@
class Int(ValueSet, Orderable):
"""A field representing a Integer."""
_type = int, long
+
=== Zope3/src/zope/schema/_schema.py 1.2 => 1.3 ===
--- Zope3/src/zope/schema/_schema.py:1.2 Wed Dec 25 09:15:20 2002
+++ Zope3/src/zope/schema/_schema.py Thu Jan 9 09:13:18 2003
@@ -15,7 +15,7 @@
$Id$
"""
from zope.interface import Interface
-from zope.schema.interfaces import ValidationError, ValidationErrorsAll
+from zope.schema.interfaces import ValidationError
def getFields(schema):
"""Get all fields on a schema.
@@ -35,33 +35,3 @@
fields = getFields(schema).items()
fields.sort(_fieldsorter)
return fields
-
-# validate functions either return silently, or raise a ValidationError
-# or in case of the validate*All functions, a ValidationErrosAll exception.
-# this should somehow be stated in an interface.
-
-def validateMapping(schema, values):
- """Pass in field values in mapping and validate whether they
- conform to schema. Stop at first error.
- """
- from zope.schema.interfaces import IField
- for name in schema.names(1):
- attr = schema.getDescriptionFor(name)
- if IField.isImplementedBy(attr):
- attr.validate(values.get(name))
-
-def validateMappingAll(schema, values):
- """Pass in field values in mapping and validate whether they
- conform to schema.
- """
- errors = []
- from zope.schema.interfaces import IField
- for name in schema.names(1):
- attr = schema.getDescriptionFor(name)
- if IField.isImplementedBy(attr):
- try:
- attr.validate(values.get(name))
- except ValidationError, e:
- errors.append((name, e))
- if errors:
- raise ValidationErrorsAll, errors
=== Zope3/src/zope/schema/interfaces.py 1.3 => 1.4 ===
--- Zope3/src/zope/schema/interfaces.py:1.3 Tue Jan 7 14:49:26 2003
+++ Zope3/src/zope/schema/interfaces.py Thu Jan 9 09:13:18 2003
@@ -11,14 +11,12 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Validation Exceptions
+"""Schema interfaces and exceptions
$Id$
"""
-
from zope.interface import Interface
-
class StopValidation(Exception):
"""This exception is raised, if the validation is done for sure early.
Note that this exception should be always caught, since it is just a
@@ -36,37 +34,10 @@
def __repr__(self):
return ' '.join(map(str, self.args))
-# XXX YAGNI, this is doomed. ;)
-
-class ErrorContainer(Exception):
- """ """
-
- def __init__(self, errors):
- Exception.__init__(self)
- self.errors = errors
-
- def __len__(self):
- return len(self.errors)
-
- def __getitem__(self, key):
- return self.errors[key]
-
- def __iter__(self):
- return iter(self.errors)
-
-
-class ValidationErrorsAll(ErrorContainer):
- """This is a collection error that contains all exceptions that occured
- during the validation process."""
-
-
-class ConversionErrorsAll(ErrorContainer):
- """This is a collection error that contains all exceptions that occured
- during the conversion process."""
-
-
+# Delay these imports to avoid circular import problems
from zope.schema._bootstrapfields import Field, Text, TextLine, Bool, Int
from zope.schema._bootstrapfields import Container, Iterable
+
class IField(Interface):
"""Basic Schema Field Interface.