[Zope3-checkins] SVN: Zope3/trunk/src/zope/schema/ Fixed a bug that
prevented non-None missing values from being assigned as
field default values.
Garrett Smith
garrett at mojave-corp.com
Mon Nov 29 16:44:19 EST 2004
Log message for revision 28534:
Fixed a bug that prevented non-None missing values from being assigned as field default values.
Changed:
U Zope3/trunk/src/zope/schema/_bootstrapfields.py
U Zope3/trunk/src/zope/schema/tests/test_setfield.py
-=-
Modified: Zope3/trunk/src/zope/schema/_bootstrapfields.py
===================================================================
--- Zope3/trunk/src/zope/schema/_bootstrapfields.py 2004-11-29 18:05:55 UTC (rev 28533)
+++ Zope3/trunk/src/zope/schema/_bootstrapfields.py 2004-11-29 21:44:19 UTC (rev 28534)
@@ -34,7 +34,7 @@
def __set__(self, inst, value):
name, check = self._info
- if value is not None:
+ if value != inst.missing_value:
if check is not None:
check(inst, value)
else:
Modified: Zope3/trunk/src/zope/schema/tests/test_setfield.py
===================================================================
--- Zope3/trunk/src/zope/schema/tests/test_setfield.py 2004-11-29 18:05:55 UTC (rev 28533)
+++ Zope3/trunk/src/zope/schema/tests/test_setfield.py 2004-11-29 21:44:19 UTC (rev 28534)
@@ -55,6 +55,22 @@
self.assertRaises(RequiredMissing, field.validate, None)
+ def testValidateRequiredAltMissingValue(self):
+ missing = object()
+ field = Set(required=True, missing_value=missing)
+ field.validate(sets.Set())
+
+ self.assertRaises(RequiredMissing, field.validate, missing)
+
+ def testValidateDefault(self):
+ field = Set(required=True)
+ field.default = None
+
+ def testValidateDefaultAltMissingValue(self):
+ missing = object()
+ field = Set(required=True, missing_value=missing)
+ field.default = missing
+
def testValidateMinValues(self):
field = Set(title=u'Set field', description=u'',
readonly=False, required=False, min_length=2)
More information about the Zope3-Checkins
mailing list