[Checkins] SVN: zope.schema/trunk/src/zope/schema/ advertise which field is invalid

Godefroid Chapelle gotcha at bubblenet.be
Mon Nov 30 06:21:26 EST 2009


Log message for revision 106109:
  advertise which field is invalid

Changed:
  U   zope.schema/trunk/src/zope/schema/README.txt
  U   zope.schema/trunk/src/zope/schema/_bootstrapfields.py
  U   zope.schema/trunk/src/zope/schema/_field.py

-=-
Modified: zope.schema/trunk/src/zope/schema/README.txt
===================================================================
--- zope.schema/trunk/src/zope/schema/README.txt	2009-11-30 11:15:32 UTC (rev 106108)
+++ zope.schema/trunk/src/zope/schema/README.txt	2009-11-30 11:21:26 UTC (rev 106109)
@@ -88,7 +88,7 @@
   >>> url_bound.validate(u'http://zope.org/foo')
   Traceback (most recent call last):
   ...
-  WrongType: (u'http://zope.org/foo', <type 'str'>)
+  WrongType: (u'http://zope.org/foo', <type 'str'>, 'url')
 
   >>> url_bound.validate('foo.bar')
   Traceback (most recent call last):

Modified: zope.schema/trunk/src/zope/schema/_bootstrapfields.py
===================================================================
--- zope.schema/trunk/src/zope/schema/_bootstrapfields.py	2009-11-30 11:15:32 UTC (rev 106108)
+++ zope.schema/trunk/src/zope/schema/_bootstrapfields.py	2009-11-30 11:21:26 UTC (rev 106109)
@@ -162,7 +162,7 @@
 
     def _validate(self, value):
         if self._type is not None and not isinstance(value, self._type):
-            raise WrongType(value, self._type)
+            raise WrongType(value, self._type, self.__name__)
 
         if not self.constraint(value):
             raise ConstraintNotSatisfied(value)
@@ -283,7 +283,7 @@
         >>> t.fromUnicode("foo x spam")
         Traceback (most recent call last):
         ...
-        WrongType: ('foo x spam', <type 'unicode'>)
+        WrongType: ('foo x spam', <type 'unicode'>, '')
         >>> t.fromUnicode(u"foo x spam")
         u'foo x spam'
         >>> t.fromUnicode(u"foo spam")

Modified: zope.schema/trunk/src/zope/schema/_field.py
===================================================================
--- zope.schema/trunk/src/zope/schema/_field.py	2009-11-30 11:15:32 UTC (rev 106108)
+++ zope.schema/trunk/src/zope/schema/_field.py	2009-11-30 11:21:26 UTC (rev 106109)
@@ -223,7 +223,7 @@
     def _validate(self, value):
         super(Date, self)._validate(value)
         if isinstance(value, datetime):
-            raise WrongType(value, self._type)
+            raise WrongType(value, self._type, self.__name__)
 
 
 class Timedelta(Orderable, Field):
@@ -335,7 +335,7 @@
     def _validate(self, value):
         super(InterfaceField, self)._validate(value)
         if not IInterface.providedBy(value):
-            raise WrongType("An interface is required")
+            raise WrongType("An interface is required", value, self.__name__)
 
 
 def _validate_sequence(value_type, value, errors=None):
@@ -355,7 +355,7 @@
 
             >>> errors = _validate_sequence(field, ('foo', u'bar', 1))
             >>> errors
-            [WrongType('foo', <type 'unicode'>), WrongType(1, <type 'unicode'>)]
+            [WrongType('foo', <type 'unicode'>, ''), WrongType(1, <type 'unicode'>, '')]
 
         The only valid value in the sequence is the second item. The others
         generated errors.
@@ -365,7 +365,7 @@
 
         >>> errors = _validate_sequence(field, (2, u'baz'), errors)
         >>> errors
-        [WrongType('foo', <type 'unicode'>), WrongType(1, <type 'unicode'>), WrongType(2, <type 'unicode'>)]
+        [WrongType('foo', <type 'unicode'>, ''), WrongType(1, <type 'unicode'>, ''), WrongType(2, <type 'unicode'>, '')]
 
     """
     if errors is None:



More information about the checkins mailing list