[Zope3-checkins] SVN: Zope3/trunk/src/zope/schema/ Fixed implementation of field 'constraint' to pass interface verify. Added test for IDate, which was previously failing verify.

Garrett Smith garrett at mojave-corp.com
Mon Nov 8 11:56:33 EST 2004


Log message for revision 28401:
  Fixed implementation of field 'constraint' to pass interface verify. Added test for IDate, which was previously failing verify.

Changed:
  U   Zope3/trunk/src/zope/schema/_bootstrapfields.py
  U   Zope3/trunk/src/zope/schema/tests/test_date.py

-=-
Modified: Zope3/trunk/src/zope/schema/_bootstrapfields.py
===================================================================
--- Zope3/trunk/src/zope/schema/_bootstrapfields.py	2004-11-08 16:49:48 UTC (rev 28400)
+++ Zope3/trunk/src/zope/schema/_bootstrapfields.py	2004-11-08 16:56:33 UTC (rev 28401)
@@ -64,7 +64,6 @@
     #    of Field (including Field subclass) instances.
     order = 0
 
-    constraint = None
     default = ValidatedProperty('default')
 
     def __init__(self, title=u'', description=u'', __name__='',
@@ -120,6 +119,9 @@
         if missing_value is not self.__missing_value_marker:
             self.missing_value = missing_value
 
+    def constraint(self, value):
+        return True
+
     def bind(self, object):
         clone = self.__class__.__new__(self.__class__)
         clone.__dict__.update(self.__dict__)
@@ -161,7 +163,7 @@
         if self._type is not None and not isinstance(value, self._type):
             raise WrongType(value, self._type)
 
-        if self.constraint is not None and not self.constraint(value):
+        if not self.constraint(value):
             raise ConstraintNotSatisfied(value)
 
     def get(self, object):

Modified: Zope3/trunk/src/zope/schema/tests/test_date.py
===================================================================
--- Zope3/trunk/src/zope/schema/tests/test_date.py	2004-11-08 16:49:48 UTC (rev 28400)
+++ Zope3/trunk/src/zope/schema/tests/test_date.py	2004-11-08 16:56:33 UTC (rev 28401)
@@ -27,6 +27,11 @@
 
     _Field_Factory = Date
 
+    def testInterface(self):
+        from zope.interface.verify import verifyObject
+        from zope.schema.interfaces import IDate
+        verifyObject(IDate, self._Field_Factory())
+
     def testValidate(self):
         field = self._Field_Factory(title=u'Date field', description=u'',
                                     readonly=False, required=False)



More information about the Zope3-Checkins mailing list