EntityLog

class app.portfolio.models.entity.entity_log.EntityLog[source]

Bases: Sequence, LoggableMixin, HierarchicalMixinMinimal, NamedMixinMinimal

Inheritance diagram of EntityLog

Inheritance Diagram for EntityLog

Methods

__init__(uid)

as_json()

Return the audit log entries as a JSON-serializable list of dictionaries.

as_json_str(**kwargs)

Return the audit log entries as a JSON string.

as_tuple()

Return the audit log entries as a list.

by_entity(entity)

by_uid(uid)

get_entry_by_version(version)

Return the audit entry for the given version, or None if no such entry exists.

on_delete_record(record[, who, why])

on_init_record(record)

revert()

Attributes

PROPAGATE_INSTANCE_NAME_FROM_PARENT

TRACK_ENTITY_DIFF

deleted

entity

entity_or_none

entity_uid

exists

in_session

instance_name

instance_parent

Return the parent entity of this instance, if it exists.

most_recent

Returns the most recent audit entry for the entity, or None if there are no entries.

next_version

Return the next version number that should be used for the entity.

record

record_or_none

session

session_manager

session_manager_or_none

session_or_none

version

Return the version of the entity at the time of the last audit entry.

PROPAGATE_INSTANCE_NAME_FROM_PARENT: ClassVar[bool] = False
TRACK_ENTITY_DIFF = True
__init__(uid: Uid) None[source]
Parameters:

uid (Uid)

Return type:

None

static __new__(cls, uid: Uid) Self[source]
Parameters:

uid (Uid)

Return type:

Self

as_json() list[dict[str, Any]][source]

Return the audit log entries as a JSON-serializable list of dictionaries.

This is useful for exporting the audit log to JSON.

Return type:

list[dict[str, Any]]

as_json_str(**kwargs) str[source]

Return the audit log entries as a JSON string.

This is useful for exporting the audit log to JSON.

Return type:

str

as_tuple() tuple[EntityLogEntry, ...][source]

Return the audit log entries as a list.

This is useful for iterating over the entries.

Return type:

tuple[EntityLogEntry, …]

classmethod by_entity(entity: Entity | EntityRecord) EntityLog | None[source]
Parameters:

entity (Entity | EntityRecord)

Return type:

EntityLog | None

classmethod by_uid(uid: Uid) EntityLog | None[source]
Parameters:

uid (Uid)

Return type:

EntityLog | None

property deleted: bool
property entity: Entity
property entity_or_none: Entity | None
property entity_uid: Uid
property exists: bool
get_entry_by_version(version: Annotated[int, Gt(gt=0)]) EntityLogEntry | None[source]

Return the audit entry for the given version, or None if no such entry exists.

Parameters:

version (Annotated[int, Gt(gt=0)])

Return type:

EntityLogEntry | None

property in_session: bool
property instance_name: str
property instance_parent: Entity | None

Return the parent entity of this instance, if it exists.

If the entity does not exist in the entity store, returns None.

property most_recent: EntityLogEntry

Returns the most recent audit entry for the entity, or None if there are no entries.

property next_version: Annotated[int, Gt(gt=0)]

Return the next version number that should be used for the entity.

This is the current version + 1.

on_delete_record(record: EntityRecord, who: str | None = None, why: str | None = None) None[source]
Parameters:
Return type:

None

on_init_record(record: EntityRecord) None[source]
Parameters:

record (EntityRecord)

Return type:

None

property record: EntityRecord
property record_or_none: EntityRecord | None
revert() None[source]
Return type:

None

property session: Session
property session_manager: SessionManager
property session_manager_or_none: SessionManager | None
property session_or_none: Session | None
property version: Annotated[int, Gt(gt=0)]

Return the version of the entity at the time of the last audit entry.

If there are no entries, returns 0.