Obtain(componentKey,[default=value]) - finds/caches a needed component
Usage examples:
class someClass(binding.Component):
thingINeed = binding.Obtain("path/to/service")
otherThing = binding.Obtain(IOtherThing)
aProperty = binding.Obtain(PropertyName('some.prop'), default=42)
someClass instances can then refer to their attributes, such as
self.thingINeed , instead of repeatedly calling
self.lookupComponent(someKey) .
The initial argument to the Obtain constructor must be adaptable to
binding.IComponentKey . If a default keyword argument is supplied,
it will be used as the default in case the specified component key is not
found.
XXX need to document IComponentKey translations somewhere... probably
w/IComponentKey
Methods
|
|
__init__
__repr__
computeValue
|
|
__init__
|
__init__ (
self,
targetName,
metadata=None,
**kw,
)
|
|
__repr__
|
__repr__ ( self )
|
|
computeValue
|
computeValue (
self,
obj,
instanceDict,
attrName,
)
|
|