Entity and aggregate base classes.
Bases: object
Abstract base class for all aggregates.
An aggregate is an accessor for a set of entities of the same type which are held in some repository.
The wrapped entity set may be a “root” set of all entities in the repository or a “relation” set defined by a relationship to entities of some other type.
Supports filtering, sorting, slicing, counting, iteration as well as retrieving, adding and removing entities.
Constructor:
Parameters: |
|
---|
list of weak references to the object (if defined)
Adds an entity to the aggregate.
If the entity has an ID, it must be unique within the aggregate.
Parameters: | entity (object implementing everest.entities.interfaces.IEntity) – entity (domain object) to add |
---|---|
Raises ValueError: | |
if an entity with the same ID exists |
Returns the total number of entities in the underlying aggregate. If specified, filter specs are applied. A specified slice key is ignored.
Returns: | number of aggregate members (int) |
---|
Factory class method to create a new aggregate.
Entity class (type) of the entities in this aggregate.
Returns an entity by ID from the underlying aggregate or None if the entity is not found.
Note : | if a filter is set which matches the requested entity, it will not be found. |
---|---|
Parameters: | id_key (int or str) – ID value to look up |
Raises : | everest.exceptions.DuplicateException if more than one entity is found for the given ID value. |
Returns: | specified entity or None |
Returns a single entity from the underlying aggregate by ID.
Returns an entity by slug or None if the entity is not found.
Parameters: | slug (str) – slug value to look up |
---|---|
Raises : | everest.exceptions.DuplicateException if more than one entity is found for the given ID value. |
Returns: | entity or None |
Returns an iterator for the entities contained in the underlying aggregate.
If specified, filter, order, and slice settings are applied.
Returns: | an iterator for the aggregate entities |
---|
Bases: object
Abstract base class for all model entities.
All entities have an ID which is used as the default value for equality comparison. The object may be initialized without an ID.
list of weak references to the object (if defined)