summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/fields.rst27
-rw-r--r--docs/narr.rst27
2 files changed, 25 insertions, 29 deletions
diff --git a/docs/fields.rst b/docs/fields.rst
index 2048b2d..118d8c4 100644
--- a/docs/fields.rst
+++ b/docs/fields.rst
@@ -28,13 +28,11 @@ Conversion from Unicode:
.. doctest::
- >>> from zope.schema._compat import b
- >>> from zope.schema._compat import u
>>> from zope.schema import Bytes
- >>> obj = Bytes(constraint=lambda v: b('x') in v)
- >>> obj.fromUnicode(u(" foo x.y.z bat"))
+ >>> obj = Bytes(constraint=lambda v: b'x' in v)
+ >>> obj.fromUnicode(u" foo x.y.z bat")
' foo x.y.z bat'
- >>> obj.fromUnicode(u(" foo y.z bat"))
+ >>> obj.fromUnicode(u" foo y.z bat")
Traceback (most recent call last):
...
ConstraintNotSatisfied: foo y.z bat
@@ -162,14 +160,14 @@ Conversion from Unicode enforces the constraint:
>>> from zope.schema.vocabulary import SimpleVocabulary
>>> from zope.schema import Choice
>>> t = Choice(
- ... vocabulary=SimpleVocabulary.fromValues([u('foo'),u('bar')]))
+ ... vocabulary=SimpleVocabulary.fromValues([u'foo',u'bar']))
>>> IFromUnicode.providedBy(t)
True
- >>> t.fromUnicode(u("baz"))
+ >>> t.fromUnicode(u"baz")
Traceback (most recent call last):
...
ConstraintNotSatisfied: baz
- >>> t.fromUnicode(u("foo"))
+ >>> t.fromUnicode(u"foo")
u'foo'
By default, ValueErrors are thrown if duplicate values or tokens
@@ -191,9 +189,9 @@ Validation ensures that the pattern is matched:
>>> from zope.schema import URI
>>> uri = URI(__name__='test')
- >>> uri.validate(b("http://www.python.org/foo/bar"))
- >>> uri.validate(b("DAV:"))
- >>> uri.validate(b("www.python.org/foo/bar"))
+ >>> uri.validate(b"http://www.python.org/foo/bar")
+ >>> uri.validate(b"DAV:")
+ >>> uri.validate(b"www.python.org/foo/bar")
Traceback (most recent call last):
...
InvalidURI: www.python.org/foo/bar
@@ -334,7 +332,7 @@ Conversion from Unicode:
>>> id = Id(__name__='test')
>>> id.fromUnicode("http://www.python.org/foo/bar")
'http://www.python.org/foo/bar'
- >>> id.fromUnicode(u(" http://www.python.org/foo/bar "))
+ >>> id.fromUnicode(u" http://www.python.org/foo/bar ")
'http://www.python.org/foo/bar'
>>> id.fromUnicode("http://www.python.org/ foo/bar")
Traceback (most recent call last):
@@ -359,12 +357,11 @@ uniqueness. In a schema, this might be written as follows:
>>> from zope.interface import Interface
>>> from zope.schema import List, Float
- >>> from zope.schema._compat import u
>>> class IInventoryItem(Interface):
... pricePoints = List(
- ... title=u("Price Points"),
+ ... title=u"Price Points",
... unique=True,
- ... value_type=Float(title=u("Price"), min=0.0)
+ ... value_type=Float(title=u"Price", min=0.0)
... )
This indicates several things.
diff --git a/docs/narr.rst b/docs/narr.rst
index 63ac1d4..7a7125b 100644
--- a/docs/narr.rst
+++ b/docs/narr.rst
@@ -36,17 +36,16 @@ instances, we now use schema fields:
>>> import zope.interface
>>> import zope.schema
- >>> from zope.schema._compat import u, b
>>> class IBookmark(zope.interface.Interface):
... title = zope.schema.TextLine(
- ... title=u('Title'),
- ... description=u('The title of the bookmark'),
+ ... title=u'Title',
+ ... description=u'The title of the bookmark',
... required=True)
...
... url = zope.schema.URI(
- ... title=u('Bookmark URL'),
- ... description=u('URL of the Bookmark'),
+ ... title=u'Bookmark URL',
+ ... description=u'URL of the Bookmark',
... required=True)
...
@@ -69,8 +68,8 @@ is to define some data:
.. doctest::
- >>> title = u('Zope 3 Website')
- >>> url = b('http://dev.zope.org/Zope3')
+ >>> title = u'Zope 3 Website'
+ >>> url = b'http://dev.zope.org/Zope3'
Now we, get the fields from the interface:
@@ -147,16 +146,16 @@ down example from the programmer's tutorial:
>>> class IContact(zope.interface.Interface):
... """Provides access to basic contact information."""
...
- ... first = zope.schema.TextLine(title=u("First name"))
+ ... first = zope.schema.TextLine(title=u"First name")
...
- ... last = zope.schema.TextLine(title=u("Last name"))
+ ... last = zope.schema.TextLine(title=u"Last name")
...
- ... email = zope.schema.TextLine(title=u("Electronic mail address"))
+ ... email = zope.schema.TextLine(title=u"Electronic mail address")
...
- ... address = zope.schema.Text(title=u("Postal address"))
+ ... address = zope.schema.Text(title=u"Postal address")
...
... postalCode = zope.schema.TextLine(
- ... title=u("Postal code"),
+ ... title=u"Postal code",
... constraint=re.compile("\d{5,5}(-\d{4,4})?$").match)
``TextLine`` is a field and expresses that an attribute is a single line
@@ -184,8 +183,8 @@ schema:
.. doctest::
- >>> someone = Contact(u('Tim'), u('Roberts'), u('tim@roberts'), u(''),
- ... u('12032-3492'))
+ >>> someone = Contact(u'Tim', u'Roberts', u'tim@roberts', u'',
+ ... u'12032-3492')
>>> for field in zope.schema.getFields(IContact).values():
... bound = field.bind(someone)