Package mrv :: Module dge :: Class Attribute
[hide private]
[frames] | no frames]

Class Attribute

source code

object --+
         |
        Attribute
Known Subclasses:

Simple class defining the type of a plug and several flags that affect it. Additionally it can determine how well suited another attribute is

Flags:
exact_type: if True, derived classes of our typecls are not considered to be a valid type. i.e: basestring could be stored in a str attr if exact type is false - its less than we need, but still something. Putting a str into a basestring attribute will always work though, as it would be more than we need readonly: if True, the attribute's plug cannot be written to. Read-only attributes can be used as storage that the user can read, but not write. You can write read-only plugs by directly setting its cache - this of course - is only for the node itself, but will never be done by the framework
computable:

Nodes are automatically computable if they are affected by another plug. If this is not the case, they are marked input only and are not computed. If this flag is true, even unaffeted plugs are computable. Plugs that affect something are automatically input plugs and will not be computed. If the plug does not affect anything and this flag is False, they are seen as input plugs anyway.

The system does not allow plugs to be input and output plugs at the same time, thus your compute cannot be triggered by your own compute

cls: if True, the plug requires classes to be set ( instances of 'type' ) , but no instances of these classes uncached: if False, computed values may be cached, otherwise they will always be recomputed. unconnectable: if True, the node cannot be the destination of a connection check_passing_values: check each value as it flows through a connection - usually compatability is only checked on connection and once values are set, but not if they flow through an existing connection

Default Values:
Although default values can be simple primitives are classes, a callable is specifically supported. It allows you to get a callback whenever a default value is required. The same result could be achieved by connected the plug in question, but dynamic defaults are a quick way to achive that. Your returned value will be type-checked against the required type if check_passing_values is set.
Instance Methods [hide private]
 
__init__(self, typeClass, flags, default=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
_getClassRating(self, cls, exact_type)
compute class rating
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

    Interface
 
affinity(self, otherattr)
Compute affinity for otherattr.
source code
 
connectionAffinity(self, destinationattr)
Compute connection affinity for given destination attribute
source code
 
compatabilityRate(self, value)
Compute value's compatability rate
source code
 
default(self)
Returns: default value stored for this attribute, or raise
source code
Class Variables [hide private]
  check_passing_values = 64
  cls = 8
  computable = 4
  exact_type = 1
  kGood = 127
  kNo = 0
  kPerfect = 255
  readonly = 2
  uncached = 16
  unconnectable = 32
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, typeClass, flags, default=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

_getClassRating(self, cls, exact_type)

source code 
compute class rating
Returns:
rating based on value being a class and compare. 0 means there is no type compatability, 255 matches comparecls, or linearly less if is just part of the mro of value

affinity(self, otherattr)

source code 
Compute affinity for otherattr.
Returns:
rating from 0 to 255 defining how good the attribtues match each other in general - how good can we store values of otherattr ? Thus this comparison is directed.

Note: for checking connections, use connectionAffinity

connectionAffinity(self, destinationattr)

source code 
Compute connection affinity for given destination attribute
Returns:
rating from 0 to 255 defining the quality of the connection to otherplug. an affinity of 0 mean connection is not possible, 255 mean the connection is perfectly suited. The connection is a directed one from self -> otherplug

compatabilityRate(self, value)

source code 
Compute value's compatability rate
Returns:
value between 0 and 255, 0 means no compatability, 255 a perfect match. if larger than 0, the plug can hold the value ( assumed the flags are set correctly ).

default(self)

source code 
Returns:
default value stored for this attribute, or raise
Raises:
  • MissingDefaultValueError - if attribute does not have a default value
  • TypeError - if value returned by dynamic attribute has incorrect type

Note: handles dynamic defaults, so you should not directly access the default member variable