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('*')
>>>
context
(type: NoneType)
Nonedefault
(type:
ValidatedProperty)
<zope.schema._bootstrapfields.ValidatedProperty object at 0x2aaab2b29710>description
(type:
FieldProperty)
<zope.schema.fieldproperty.FieldProperty object at 0x2aaab2b14b50>interface
(type: NoneType)
Nonemissing_value
(type: NoneType)
Noneorder
(type:
int)
632readonly
(type:
FieldProperty)
<zope.schema.fieldproperty.FieldProperty object at 0x2aaab2d47110>required
(type:
FieldProperty)
<zope.schema.fieldproperty.FieldProperty object at 0x2aaab2b14b10>title
(type:
FieldProperty)
<zope.schema.fieldproperty.FieldProperty object at 0x2aaab2b14ad0>bind(object)
constraint(value)
fromUnicode(u)
get(object)
getDoc()
Returns the documentation for the object.
getName()
Returns the name of the object.
getTaggedValue(tag)
Returns the value associated with tag.
getTaggedValueTags()
Returns a list of all tags.
query(object, default=None)
queryTaggedValue(tag, default=None)
Returns the value associated with tag.
set(object, value)
setTaggedValue(tag, value)
Associates value with key.
validate(value)