Class
zope.configuration.fields.GlobalObject

An object that can be accessed as a module global.

Examples:

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

>>> d = {'x': 1, 'y': 42, 'z': 'zope'}
>>> class fakeresolver(dict):
...     def resolve(self, n):
...         return self[n]
>>> fake = fakeresolver(d)
>>> g = GlobalObject(value_type=schema.Int())
>>> gg = g.bind(fake)
>>> gg.fromUnicode("x")
1
>>> gg.fromUnicode("   x  \n  ")
1
>>> gg.fromUnicode("y")
42
>>> gg.fromUnicode("z")
Traceback (most recent call last):
...
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):
...
ConstraintNotSatisfied: 1
>>> gg.fromUnicode("y")
42
>>> g = GlobalObject()
>>> gg = g.bind(fake)
>>> gg.fromUnicode('*')
>>>

Base classes

Implemented Interfaces

Attributes/Properties

Methods

Known Subclasses