bento_meta.entity
This module contains * Entity, the base class for metamodel objects, * the CollValue class to manage collection-valued attributes, and * the ArgError exception.
Exceptions
Exception for method argument errors. |
Classes
Base class for all metamodel objects. |
|
A UserDict for housing Entity collection attributes. |
Module Contents
- exception bento_meta.entity.ArgError[source]
Bases:
Exception
Exception for method argument errors.
- class bento_meta.entity.Entity(init: dict | neo4j.graph.Node | Entity | None = None)[source]
Base class for all metamodel objects.
Entity contains all the magic for metamodel objects such as bento_meta.objects.Node and ‘bento_meta.object.Edge`. It will rarely be used directly. Entity redefines __setattr__ and __getattr__ to enable graph database object mapping under the hood.
The Entity class also defines private and declared attributes that are common to all metamodel objects. It provides the machinery to manage private attributes separately from declared attributes, and to raise exceptions when attempts are made to access attributes that are not declared.
- pvt_attr = ['pvt', 'neoid', 'dirty', 'removed_entities', 'attspec', 'mapspec', 'belongs']
- defaults
- attspec_
- attspec
- mapspec_
- property object_map
- pvt
- neoid = None
- property dirty
Flag whether this instance has been changed since retrieval from the database.
Set to -1, ensure that the next time an attribute is accessed, the instance will retrieve itself from the database.
- property removed_entities
- property belongs
Dict that stores information on the owners (referents) of this instance in the model
- classmethod mapspec() dict[str, str | dict[str, str]] [source]
The object to database mapping specification.
Is a class method, not a property.
- classmethod default(propname)[source]
Returns a default value for the property named, or None if no default defined.
- get_by_id(id: str)[source]
Get an object from the db with the id attribute (not the Neo4j id).
Returns a new object. :param string id: value of id for desired object
- class bento_meta.entity.CollValue(init=None, *, owner: Entity, owner_key: str)[source]
Bases:
collections.UserDict
A UserDict for housing Entity collection attributes.
This class contains a hook for recording the Entity that owns the value that is being set. The value is marked as belonging to the containing object, not this collection object. It also protects against adding arbitrarily typed elements to the collection; it throws unless a value to set is an Entity. __setitem__.
- Parameters:
owner – Entity object of which this collection is an attribute
owner_key – the attribute name of this collection on the owner
- property owner_key: str
The attribute name of this collection on the owner.