[Zope3-checkins] CVS: Zope3/src/zope/schema - _field.py:1.28
interfaces.py:1.39
Philipp von Weitershausen
philikon at philikon.de
Thu Jan 22 11:31:28 EST 2004
Update of /cvs-repository/Zope3/src/zope/schema
In directory cvs.zope.org:/tmp/cvs-serv30647
Modified Files:
_field.py interfaces.py
Log Message:
Reflect the actual meaning of the ASCII schema field, a 7bit string. See
http://mail.zope.org/pipermail/zope3-dev/2004-January/009407.html for some
discussion.
=== Zope3/src/zope/schema/_field.py 1.27 => 1.28 ===
--- Zope3/src/zope/schema/_field.py:1.27 Fri Jan 16 08:38:20 2004
+++ Zope3/src/zope/schema/_field.py Thu Jan 22 11:31:27 2004
@@ -1,3 +1,4 @@
+# -*- coding: ISO-8859-1 -*-
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
@@ -96,6 +97,31 @@
__doc__ = IASCII.__doc__
implements(IASCII)
+ def _validate(self, value):
+ """
+ >>> ascii = ASCII()
+
+ Make sure we accept empty strings:
+
+ >>> empty = ''
+ >>> ascii._validate(empty)
+
+ and all kinds of alphanumeric strings:
+
+ >>> alphanumeric = "Bob\'s my 23rd uncle"
+ >>> ascii._validate(alphanumeric)
+
+ >>> umlauts = "Köhlerstraße"
+ >>> ascii._validate(umlauts)
+ Traceback (most recent call last):
+ ...
+ ValidationError: Invalid value
+ """
+ super(ASCII, self)._validate(value)
+ if not value:
+ return
+ if not max(map(ord, value)) < 128:
+ raise ValidationError(errornames.InvalidValue)
class BytesLine(Bytes):
"""A Text field with no newlines."""
=== Zope3/src/zope/schema/interfaces.py 1.38 => 1.39 ===
--- Zope3/src/zope/schema/interfaces.py:1.38 Fri Jan 16 08:38:20 2004
+++ Zope3/src/zope/schema/interfaces.py Thu Jan 22 11:31:27 2004
@@ -260,8 +260,9 @@
The value might be constrained to be with length limits.
"""
-class IASCII(IMinMaxLen, IIterable, IField):
- u"""Field containing a byte string (like the python str).
+class IASCII(IBytes):
+ u"""Field containing a 7-bit ASCII string. No characters > DEL
+ (chr(127)) are allowed
The value might be constrained to be with length limits.
"""
More information about the Zope3-Checkins
mailing list