Class
zope.configuration.fields.Tokens

A list that can be read from a space-separated string

Consider GlobalObject tokens:

Examples:

First, we need to set up a stub name resolver:

>>> d = {'x': 1, 'y': 42, 'z': 'zope', 'x.y.x': 'foo'}
>>> class fakeresolver(dict):
...     def resolve(self, n):
...         return self[n]
>>> fake = fakeresolver(d)
>>> g = Tokens(value_type=GlobalObject())
>>> gg = g.bind(fake)
>>> gg.fromUnicode("  \n  x y z  \n")
[1, 42, 'zope']
>>> g = Tokens(value_type=
...            GlobalObject(value_type=
...                         schema.Int(constraint=lambda x: x%2 == 0)))
>>> gg = g.bind(fake)
>>> gg.fromUnicode("x y")
Traceback (most recent call last):
...
InvalidToken: 1 in x y
>>> gg.fromUnicode("z y")
Traceback (most recent call last):
...
InvalidToken: ('zope', (<type 'int'>, <type 'long'>)) in z y
>>> gg.fromUnicode("y y")
[42, 42]
>>>

Base classes

Implemented Interfaces

Attributes/Properties

Methods

Known Subclasses

There are no known subclasses.