mango.relations.base module

class mango.relations.base.Relation(cls, name=None, rev_name=None, rev_array=None, rev_hidden=None, rev_relation=None, hidden=False, persist=True, typed=False, on_delete=0, multi=False, validators=())

Bases: object

The relationship class is the base descriptor that can be subclassed and used in the models. The descriptors have the possibility to link to other classes and it is possible to add a reverse link as well.

add_manager_to_instance(instance)

Add a connection attribute to the instance. The connection attribute is a maya message attribute, depending on the multi and rev settings the connection will be hidden and is determined to only be a source or a destination. When a relation is set to be hidden the attribute is hidden. The attribute is controlled by a manager. This manager gets stored on the instance and will be returned.

Parameters:instance (models.Model) –
Returns:Manager
Return type:managers.Manager
generate_rev_name(name)

Generate a rev name based of the provided object and if its a multi object or not. If it is an s will be appended to the name if the name doesn’t already end with an s.

Parameters:name (str) –
Returns:Rev name
Return type:str
get_manager_from_instance(instance)
Parameters:instance (models.Model) –
Returns:Manager
Return type:managers.Manager