[Zope-Checkins] CVS: Zope/lib/python/Controller - schemaclasses.py:1.1.2.5
Fred L. Drake, Jr.
fred@zope.com
Mon, 2 Dec 2002 11:51:38 -0500
Update of /cvs-repository/Zope/lib/python/Controller
In directory cvs.zope.org:/tmp/cvs-serv5015
Modified Files:
Tag: chrism-install-branch
schemaclasses.py
Log Message:
_bool.validate(): For some reason, this would accept lots of invalid
values for both true and false. For example, 'ontology' and
'official' evaluated to true and false, respectively.
Simplified the tests and made the accepted values more constrained for
the _bool mixin.
=== Zope/lib/python/Controller/schemaclasses.py 1.1.2.4 => 1.1.2.5 ===
--- Zope/lib/python/Controller/schemaclasses.py:1.1.2.4 Tue Nov 26 18:42:15 2002
+++ Zope/lib/python/Controller/schemaclasses.py Mon Dec 2 11:51:38 2002
@@ -88,17 +88,12 @@
class _bool:
def validate(self, value):
- if value.startswith('on'):
+ if value in ('on', 'off'):
return
- if value.startswith('off'):
- return
- return 'Value be one of "on" or "off"'
+ return 'Value must be one of "on" or "off"'
def bool(self, value):
- if value.startswith('on'):
- return 1
- else:
- return 0
+ return value == 'on'
class _int:
def validate(self, value):