Package multivac :: Class Element
[hide private]
[frames] | no frames]

Class Element

source code


Mapping class for the table «element».

Instance Methods [hide private]
int
id(self)
Read only accessor to prevent setting this field.
source code
set<Element>
children(self)
The collection of child Elements of this instance.
source code
int
parent_id(self)
Read only accessor to prevent setting this field.
source code
 
parent(self, parent)
Setter for the related parent Element of this instance.
source code
int
project_id(self)
Read only accessor to prevent setting this field.
source code
 
project(self, project)
Setter for the related Project of this instance.
source code
 
status(self, status)
Setter for the status of this instance.
source code
 
__init__(self, *args, **kwargs)
Constructor for Element instances.
source code
 
_cascade_status(self)
Propagate its status to its parent, in a recursive manner.
source code
list<Element>
ancestors(self)
Retrieve all the ancestors of this node.
source code
str
__repr__(self)
Returns a printable representation of this instance.
source code
str
__str__(self)
Coerces this instance to a string.
source code

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

Class Methods [hide private]
 
_children_added(cls, parent, child, initiator)
Listener to be executed when an element has to be added to a children collection.
source code
 
_children_removed(cls, parent, child, initiator)
Listener to be executed when an element has to be removed from a children collection.
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

id(self)

source code 

Read only accessor to prevent setting this field.

Returns: int
Surrogate primary key
Decorators:
  • @hybrid_property

children(self)

source code 

The collection of child Elements of this instance.

Returns: set<Element>
This instance collection of children Elements
Decorators:
  • @hybrid_property

parent_id(self)

source code 

Read only accessor to prevent setting this field.

Returns: int
Foreign key for the parent Element relationship
Decorators:
  • @hybrid_property

parent(self, parent)

source code 

Setter for the related parent Element of this instance. Ensures project coherence between itself and the parent, and proper children collection initialization. Also cascades status changes.

Parameters:
  • parent (Element) - The parent Element to be assigned
Decorators:
  • @parent.setter

project_id(self)

source code 

Read only accessor to prevent setting this field.

Returns: int
Foreign key for the parent Project relationship
Decorators:
  • @hybrid_property

project(self, project)

source code 

Setter for the related Project of this instance. Prevents a second assignation.

Parameters:
  • project (Project) - The Project to be assigned
Decorators:
  • @project.setter

status(self, status)

source code 

Setter for the status of this instance. Ensures the cascade of a status change.

Parameters:
  • status (str) - The status to be assigned
Decorators:
  • @status.setter

__init__(self, *args, **kwargs)
(Constructor)

source code 

Constructor for Element instances. Ensures that the «forced_status» field is assigned first to cascade status properly.

Parameters:
  • args (tuple) - Optional arguments to the constructor
  • kwargs (dict) - Optional keyword arguments to the constructor
Overrides: object.__init__

_children_added(cls, parent, child, initiator)
Class Method

source code 

Listener to be executed when an element has to be added to a children collection. Check the added child status and update the parent's one.

Parameters:
  • parent (Element) - The Element that has a new child added
  • child (Element) - The Element being added as a child

_children_removed(cls, parent, child, initiator)
Class Method

source code 

Listener to be executed when an element has to be removed from a children collection. Check the removed child status and update the parent's one.

Parameters:
  • parent (Element) - The Element that has a child removed
  • child (Element) - The Element being removed as a child

ancestors(self)

source code 

Retrieve all the ancestors of this node. If the node has no parents, return an empty list. Else, start retrieving them from the identity map and, when not there, fetch the rest from the database using a CTE.

Returns: list<Element>
A list of all the ancestors of this node, ordered by proximity.
Decorators:
  • @property

__repr__(self)
(Representation operator)

source code 

Returns a printable representation of this instance.

Returns: str
A descriptive string containing most of this instance fields
Overrides: object.__repr__

__str__(self)
(Informal representation operator)

source code 

Coerces this instance to a string.

Returns: str
The name field
Overrides: object.__str__