Method-exporting Property (metaclass for StructuralFeature)
This metaclass adds property support to MethodExporter by adding
__get__, __set__, and __delete__ methods, which are delegated
to the method templates for the get, set and unset verbs.
In other words, if you define a feature foo, following standard
naming patterns for its set, get and unset verbs, and bar is
an Element whose class includes the foo feature, then bar.foo = 1
is equivalent to bar.setFoo(1). Similarly, referencing bar.foo by
itself is equivalent to bar.getFoo(), and del bar.foo is equivalent
to bar.unsetFoo().
Please see the peak.model.method_exporter.MethodExporter class
documentation for more detail on how method templates are defined,
the use of naming conventions, verbs, template variants, etc.
|
Methods
|
|
|
|
|
|
__delete__
|
__delete__ ( self, ob )
Delete the feature's value by delegating to ob.unsetX()
|
Exceptions
|
|
AttributeError( "Unchangeable feature", self.attrName )
|
|
|
|
__get__
|
__get__ (
self,
ob,
typ=None,
)
Get the feature's value by delegating to ob.getX()
|
|
|
__set__
|
__set__ (
self,
ob,
val,
)
Set the feature's value by delegating to ob.setX()
|
Exceptions
|
|
AttributeError( "Unchangeable feature", self.attrName )
|
|
|
|
_defaultValue
|
_defaultValue ( self )
|
|
|
_hashAndCompare
|
_hashAndCompare ( self )
Features hash and compare based on position, name, and identity
Specifically, a feature is hashed and compared as though it were
a tuple of its sortPosn, __name__, and id().
|
|
|
_syntax
|
_syntax ( feature )
|
|
|
activateInClass
|
activateInClass (
self,
klass,
attrName,
)
|
|
|
format
|
format ( self, value )
|
|
|
isReference
|
isReference ( self )
Does the feature refer to a non-primitive/non-struct type?
|
|
|
parse
|
parse ( self, aString )
|
|
|
rawTypeCode
|
rawTypeCode ( self )
|
|
|
typeObject
|
typeObject ( self )
The actual type referred to by referencedType
Since a feature's referencedType can be either a string or
a type, the actual type object is cached in the typeObject
attribute. If you need to get the type of feature aFeature,
just refer to aFeature.typeObject. This will of course fail
if the referencedType attribute is invalid.
|
|