[Zope3-checkins] CVS: Zope3/src/zope/configuration - config.py:1.26
fields.py:1.19 interfaces.py:1.6
Stephan Richter
srichter at cosmos.phy.tufts.edu
Sun Apr 11 06:35:01 EDT 2004
Update of /cvs-repository/Zope3/src/zope/configuration
In directory cvs.zope.org:/tmp/cvs-serv4643/src/zope/configuration
Modified Files:
config.py fields.py interfaces.py
Log Message:
Convert errornames to ValidationError classes. Update tests accordingly.
=== Zope3/src/zope/configuration/config.py 1.25 => 1.26 ===
--- Zope3/src/zope/configuration/config.py:1.25 Mon Mar 29 10:09:05 2004
+++ Zope3/src/zope/configuration/config.py Sun Apr 11 06:35:00 2004
@@ -31,7 +31,7 @@
from zope.interface.adapter import AdapterRegistry
from zope.interface import Interface, implements, directlyProvides, providedBy
from zope.interface.interfaces import IInterface
-from zope.schema.errornames import WrongType
+from zope.schema.interfaces import WrongType
from zope.configuration import fields
@@ -959,7 +959,7 @@
def _validate(self, value):
super(fields.GlobalObject, self)._validate(value)
if not IInterface.providedBy(value):
- raise zope.schema.ValidationError(WrongType, value)
+ raise WrongType(value)
class IDirectivesInfo(Interface):
@@ -1259,8 +1259,7 @@
... 'u': u'http://www.zope.org', 'a': u'1'}))
Traceback (most recent call last):
...
- ConfigurationError: ('Invalid value for', 'in',""" \
- """ "(u'Constraint not satisfied', 0)")
+ ConfigurationError: ('Invalid value for', 'in', '0')
"""
=== Zope3/src/zope/configuration/fields.py 1.18 => 1.19 ===
--- Zope3/src/zope/configuration/fields.py:1.18 Mon Jan 5 03:06:44 2004
+++ Zope3/src/zope/configuration/fields.py Sun Apr 11 06:35:00 2004
@@ -18,8 +18,10 @@
import os, re, warnings
from zope import schema
from zope.schema.interfaces import IFromUnicode
+from zope.schema.interfaces import ConstraintNotSatisfied
from zope.configuration.exceptions import ConfigurationError
from zope.interface import implements
+from zope.configuration.interfaces import InvalidToken
PYIDENTIFIER_REGEX = u'\A[a-zA-Z_]+[a-zA-Z0-9_]*\Z'
pyidentifierPattern = re.compile(PYIDENTIFIER_REGEX)
@@ -96,14 +98,14 @@
>>> gg.fromUnicode("z")
Traceback (most recent call last):
...
- ValidationError: (u'Wrong type', 'zope', (<type 'int'>, <type 'long'>))
+ WrongType: ('zope', (<type 'int'>, <type 'long'>))
>>> g = GlobalObject(constraint=lambda x: x%2 == 0)
>>> gg = g.bind(fake)
>>> gg.fromUnicode("x")
Traceback (most recent call last):
...
- ValidationError: (u'Constraint not satisfied', 1)
+ ConstraintNotSatisfied: 1
>>> gg.fromUnicode("y")
42
>>> g = GlobalObject()
@@ -168,13 +170,12 @@
>>> gg.fromUnicode("x y")
Traceback (most recent call last):
...
- ValidationError: Invalid token: (u'Constraint not satisfied', 1) in x y
+ InvalidToken: 1 in x y
>>> gg.fromUnicode("z y")
Traceback (most recent call last):
...
- ValidationError: Invalid token: (u'Wrong type', 'zope', """ \
- """(<type 'int'>, <type 'long'>)) in z y
+ InvalidToken: ('zope', (<type 'int'>, <type 'long'>)) in z y
>>> gg.fromUnicode("y y")
[42, 42]
>>>
@@ -191,8 +192,7 @@
try:
v = vt.fromUnicode(s)
except schema.ValidationError, v:
- raise schema.ValidationError("Invalid token: %s in %s"
- % (v, u))
+ raise InvalidToken("%s in %s" % (v, u))
else:
values.append(v)
else:
=== Zope3/src/zope/configuration/interfaces.py 1.5 => 1.6 ===
--- Zope3/src/zope/configuration/interfaces.py:1.5 Mon Mar 1 08:25:47 2004
+++ Zope3/src/zope/configuration/interfaces.py Sun Apr 11 06:35:00 2004
@@ -11,9 +11,16 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""Zope Configuration (ZCML) interfaces
+$Id$
+"""
from zope.interface import Interface
from zope.schema import BytesLine
+from zope.schema.interfaces import ValidationError
+
+class InvalidToken(ValidationError):
+ """Invaid token in list."""
class IConfigurationContext(Interface):
"""Configuration Context
More information about the Zope3-Checkins
mailing list