flask_boilerplate.domain.entities package

Submodules

flask_boilerplate.domain.entities.entity_example module

Module defining an example entity in the domain layer.

Entities are domain objects that have a unique identity and lifecycle. They are defined by their attributes and behavior, and they encapsulate business logic related to their identity and state.

This module provides an example entity ExampleEntity that demonstrates how to define entities in the domain layer. Entities typically have a unique identifier and attributes that represent their state.

class flask_boilerplate.domain.entities.entity_example.EntityExample(name: str, description: str, id: UUID = <factory>)[source]

Bases: Entity

An example entity in the domain layer.

This entity represents a domain object with a unique identity and attributes. It encapsulates business logic related to its identity and state.

name

The name of the entity.

Type:

str

description

A description of the entity.

Type:

str

id

The unique identifier of the entity.

Type:

UUID

__eq__(other: object) bool[source]

Compare two entities based on their unique identifier.

Parameters:

other (object) – The other entity to compare with.

Returns:

True if the entities have the same identifier, False otherwise.

Return type:

bool

__hash__() int[source]

Generate a hash value for the entity based on its unique identifier.

Returns:

The hash value of the entity.

Return type:

int

__post_init__() None[source]

Post-initialization hook to ensure the entity is properly initialized. If no ID is provided, it will be generated by the parent class Entity.

__str__() str[source]

Return a string representation of the entity.

The string is formatted as: EntityExample(id=<UUID>, name=<name>, description=<description>)

This format ensures consistency and readability when displaying the entity.

description: str
id: UUID
name: str
to_dict() dict[str, str][source]

Convert the entity to a dictionary representation.

Returns:

A dictionary containing the entity’s attributes.

Return type:

dict

update_description(new_description: str) None[source]

Update the description of the entity.

Parameters:

new_description (str) – The new description for the entity.

update_name(new_name: str) None[source]

Update the name of the entity.

Parameters:

new_name (str) – The new name for the entity.

validate() None[source]

Validate the entity’s data.

Raises:

EntitiesError – If the entity’s data is invalid.

Module contents

Module for exporting entities in the domain layer.

This module serves as the entry point for all entities in the domain layer. It re-exports entities to make them easily accessible from a single location.

Entities are domain objects that have a unique identity and lifecycle. They encapsulate business logic related to their identity and state.

Example

>>> from flask_boilerplate.domain.entities import EntityExample
>>> entity = EntityExample(id=UUID("..."), name="Example", description="An example entity")
class flask_boilerplate.domain.entities.EntityExample(name: str, description: str, id: UUID = <factory>)[source]

Bases: Entity

An example entity in the domain layer.

This entity represents a domain object with a unique identity and attributes. It encapsulates business logic related to its identity and state.

name

The name of the entity.

Type:

str

description

A description of the entity.

Type:

str

id

The unique identifier of the entity.

Type:

UUID

__eq__(other: object) bool[source]

Compare two entities based on their unique identifier.

Parameters:

other (object) – The other entity to compare with.

Returns:

True if the entities have the same identifier, False otherwise.

Return type:

bool

__hash__() int[source]

Generate a hash value for the entity based on its unique identifier.

Returns:

The hash value of the entity.

Return type:

int

__post_init__() None[source]

Post-initialization hook to ensure the entity is properly initialized. If no ID is provided, it will be generated by the parent class Entity.

__str__() str[source]

Return a string representation of the entity.

The string is formatted as: EntityExample(id=<UUID>, name=<name>, description=<description>)

This format ensures consistency and readability when displaying the entity.

description: str
id: UUID
name: str
to_dict() dict[str, str][source]

Convert the entity to a dictionary representation.

Returns:

A dictionary containing the entity’s attributes.

Return type:

dict

update_description(new_description: str) None[source]

Update the description of the entity.

Parameters:

new_description (str) – The new description for the entity.

update_name(new_name: str) None[source]

Update the name of the entity.

Parameters:

new_name (str) – The new name for the entity.

validate() None[source]

Validate the entity’s data.

Raises:

EntitiesError – If the entity’s data is invalid.