edgegraph.structure.base.BaseObject#
- class edgegraph.structure.base.BaseObject(*, uid=None, attributes=None, universes=None)#
Bases:
objectTop of the object inheritance tree for everything.
That’s not quite a joke – this class is the top of the tree when it comes to object types. All other objects in edgegraph inherit from this one.
It provides a few standardized attributes and access methods:
Universal unique identifier
Dynamic attributes storage
Universe association
Through the “dynamic attributes storage”, this object works as a namespace – it is intended for adding attributes after initialization / instantiation. For example:
>>> b = BaseObject() >>> dir(b) [] >>> b.x = 17 >>> b.x 17 >>> dir(b) ['x']
The attributes provided to the
__init__method also become a part of this operation:>>> b = BaseObject(attributes={"fifteen": 15}) >>> dir(b) ['fifteen'] >>> b.fifteen 15
- __init__(*, uid=None, attributes=None, universes=None)#
Instantiate a BaseObject.
- Parameters:
- Raises:
TypeError – if
attributesargument is of invalid type
Methods
__init__(*[, uid, attributes, universes])Instantiate a BaseObject.
add_to_universe(universe)Add this object to a new universe.
remove_from_universe(universe)Remove this object from the specified universe.
Attributes
- add_to_universe(universe)#
Add this object to a new universe.
If it is already there, no action is taken.
- Parameters:
universe (Universe) – the new universe to add this object to
- remove_from_universe(universe)#
Remove this object from the specified universe.
- Parameters:
universe (Universe) – the universe that this object will be removed from
- Raises:
ValueError – if this object is not present in the given universe
- property universes: list[Universe]#
Get the universes this object belongs to.
Note that the copy returned is just that, a copy. Modifications to this list that you may make will have no effect on the object.
See also
add_to_universe(),remove_from_universe()to add or remove this object from a given universe