[Zope3-checkins] CVS: Zope3/src/zope/configuration - fields.py:1.7
Stephan Richter
srichter@cosmos.phy.tufts.edu
Sat, 2 Aug 2003 12:36:33 -0400
Update of /cvs-repository/Zope3/src/zope/configuration
In directory cvs.zope.org:/tmp/cvs-serv29486/src/zope/configuration
Modified Files:
fields.py
Log Message:
Jim had already an URI field in zope.schema. Remove mine and update xml
namespace accordingly.
=== Zope3/src/zope/configuration/fields.py 1.6 => 1.7 ===
--- Zope3/src/zope/configuration/fields.py:1.6 Sat Aug 2 02:51:23 2003
+++ Zope3/src/zope/configuration/fields.py Sat Aug 2 12:35:58 2003
@@ -23,10 +23,6 @@
PYIDENTIFIER_REGEX = u'\A[a-zA-Z_]+[a-zA-Z0-9_]*\Z'
pyidentifierPattern = re.compile(PYIDENTIFIER_REGEX)
-# This regex is originally from 4Suite/Ft/Lib/Uri.py
-URI_REGEX = r"\A(?:(?:[a-zA-Z][0-9a-zA-Z+\-\.]*:)?" \
- r"/{0,2}[0-9a-zA-Z;/?:@&=+$\.\-_!~*'()%]+)?\Z"
-uriPattern = re.compile(URI_REGEX)
class PythonIdentifier(schema.TextLine):
r"""This field describes a python identifier, i.e. a variable name.
@@ -257,44 +253,6 @@
return self.context.path(u)
-class URI(schema.TextLine):
- r"""This field describes URIs, and validates the input accordingly.
-
- Let's look at an example:
-
- >>> class FauxContext:
- ... pass
- >>> context = FauxContext()
- >>> field = URI().bind(context)
-
- Let's test the fromUnicode method:
-
- >>> field.fromUnicode(u'http://www.zope3.org')
- u'http://www.zope3.org'
-
- Now let's see whether validation works alright
-
- >>> res = field._validate(u'http://www.zope3.org')
- >>> res # Result should be None
- >>>
- >>> from zope import schema
- >>> try:
- ... res = field._validate(u'http:/\\www.zope3.org')
- ... except schema.ValidationError:
- ... print 'Validation Error'
- Validation Error
-
- """
-
- implements(IFromUnicode)
-
- def fromUnicode(self, u):
- return u.strip()
-
- def _validate(self, value):
- super(URI, self)._validate(value)
- if uriPattern.match(value) is None:
- raise schema.ValidationError(value)
class Bool(schema.Bool):
"""A boolean value