Package zope :: Package configuration :: Module fields :: Class GlobalObject
[show private | hide private]
[frames | no frames]

Type GlobalObject

object --+            
         |            
   Element --+        
             |        
     Attribute --+    
                 |    
             Field --+
                     |
                    GlobalObject

Known Subclasses:
GlobalInterface

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('*')
>>>

Method Summary
  __init__(self, value_type, **kw)
  fromUnicode(self, u)
  _validate(self, value)
    Inherited from Field
  __eq__(self, other)
  __ne__(self, other)
  bind(self, object)
  constraint(self, value)
  get(self, object)
  query(self, object, default)
  set(self, object, value)
  validate(self, value)
    Inherited from Element
  getDoc(self)
Returns the documentation for the object.
  getName(self)
Returns the name of the object.
  getTaggedValue(self, tag)
Returns the value associated with 'tag'.
  getTaggedValueTags(self)
Returns a list of all tags.
  queryTaggedValue(self, tag, default)
Returns the value associated with 'tag'.
  setTaggedValue(self, tag, value)
Associates 'value' with 'key'.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Class Variable Summary
Implements __implemented__ = <implementedBy zope.configuration.fiel...
ClassProvides __provides__ = <zope.interface.declarations.ClassProvide...
    Inherited from Field
object _Field__missing_value_marker = <object object at 0xb7e6e...
NoneType _type = None                                                                  
NoneType context = None                                                                  
ValidatedProperty default = <zope.schema._bootstrapfields.ValidatedPropert...
FieldProperty description = <zope.schema.fieldproperty.FieldProperty o...
NoneType missing_value = None                                                                  
int order = 285                                                                   
FieldProperty readonly = <zope.schema.fieldproperty.FieldProperty obje...
FieldProperty required = <zope.schema.fieldproperty.FieldProperty obje...
FieldProperty title = <zope.schema.fieldproperty.FieldProperty object ...
    Inherited from Attribute
NoneType interface = None                                                                  
    Inherited from Element
ClassProvides __providedBy__ = <zope.interface.declarations.ClassProvi...

Class Variable Details

__implemented__

Type:
Implements
Value:
<implementedBy zope.configuration.fields.GlobalObject>                 

__provides__

Type:
ClassProvides
Value:
<zope.interface.declarations.ClassProvides object at 0xb64a0dcc>       

Generated by Epydoc 2.1 on Fri Jun 24 12:01:23 2005 http://epydoc.sf.net