EntityLog
- class app.portfolio.models.entity.entity_log.EntityLog[source]
Bases:
Sequence
,LoggableMixin
,HierarchicalMixinMinimal
,NamedMixinMinimal
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
Return the parent entity of this instance, if it exists.
Returns the most recent audit entry for the entity, or None if there are no entries.
Return the next version number that should be used for the entity.
Return the version of the entity at the time of the last audit entry.
- TRACK_ENTITY_DIFF = True
- 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.
- 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:
- 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
- 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:
- Return type:
EntityLogEntry | None
- 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:
record (EntityRecord)
who (str | None)
why (str | None)
- 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
- property session_manager: SessionManager
- property session_manager_or_none: SessionManager | None