[Zope3-checkins] CVS: Zope3/src/zope/schema -
_bootstrapfields.py:1.31
Garrett Smith
garrett at mojave-corp.com
Tue May 11 07:20:09 EDT 2004
Update of /cvs-repository/Zope3/src/zope/schema
In directory cvs.zope.org:/tmp/cvs-serv21596/src/zope/schema
Modified Files:
_bootstrapfields.py
Log Message:
Added support for converting unicode to Bool. Driver for this was the need
to specify a widget's 'required' value in ZCML.
=== Zope3/src/zope/schema/_bootstrapfields.py 1.30 => 1.31 ===
--- Zope3/src/zope/schema/_bootstrapfields.py:1.30 Mon Apr 26 19:15:01 2004
+++ Zope3/src/zope/schema/_bootstrapfields.py Tue May 11 07:20:09 2004
@@ -318,6 +318,23 @@
if isinstance(value, int):
value = bool(value)
Field.set(self, object, value)
+
+ def fromUnicode(self, str):
+ """
+ >>> b = Bool()
+ >>> b.fromUnicode('True')
+ True
+ >>> b.fromUnicode('')
+ False
+ >>> b.fromUnicode('true')
+ True
+ >>> b.fromUnicode('false') or b.fromUnicode('False')
+ False
+ """
+ v = str == 'True' or str == 'true'
+ self.validate(v)
+ return v
+
class Int(Orderable, Field):
"""A field representing an Integer."""
More information about the Zope3-Checkins
mailing list