EntityBase

class app.portfolio.models.entity.entity_base.EntityBase[source]

Bases: CachedTypeHintsMixin, LoggableHierarchicalModel, NamedMixinMinimal, Generic

Inheritance diagram of EntityBase

Inheritance Diagram for EntityBase

Methods

__init__(**data)

by_record(record)

by_uid(uid)

by_uid_or_none(uid)

calculate_instance_name_from_arbitrary_data(data)

calculate_instance_name_from_dict(data)

calculate_instance_name_from_instance(instance)

call_record_method(name, *args, **kwargs)

delete()

get_record_type(cls[, source])

Resolve and cache the concrete parent argument defined by the descriptor.

is_reachable(*[, recursive, use_journal])

model_post_init(context)

narrow_to_instance(value)

narrow_to_instance_or_none(value)

narrow_to_uid(value)

on_delete_record()

on_init_record(record)

revert()

sort_key()

uid_namespace()

Return the namespace for the UID.

update(**kwargs)

Attributes

PROPAGATE_INSTANCE_NAME_FROM_PARENT

children

deleted

entity

entity_or_none

exists

in_session

marked_for_deletion

model_config

Configuration for the model, should be a dictionary conforming to ConfigDict.

record

record_or_none

session

session_manager

session_manager_or_none

session_or_none

superseded

superseding

version

instance_name

uid

entity_log

entity_dependents

instance_parent_weakref

PROPAGATE_INSTANCE_NAME_FROM_PARENT: ClassVar[bool] = False
__init__(**data) None[source]
Return type:

None

static __new__(cls, uid: Uid | None = None, **data) Self[source]
Parameters:

uid (Uid | None)

Return type:

Self

classmethod by_record(record: EntityRecord) Self[source]
Parameters:

record (EntityRecord)

Return type:

Self

classmethod by_uid(uid: Uid) Self[source]
Parameters:

uid (Uid)

Return type:

Self

classmethod by_uid_or_none(uid: Uid) Self | None[source]
Parameters:

uid (Uid)

Return type:

Self | None

classmethod calculate_instance_name_from_arbitrary_data(data: Any) str[source]
Parameters:

data (Any)

Return type:

str

abstractmethod classmethod calculate_instance_name_from_dict(data: Mapping[str, Any]) str[source]
Parameters:

data (Mapping[str, Any])

Return type:

str

classmethod calculate_instance_name_from_instance(instance: EntityBase) str[source]
Parameters:

instance (EntityBase)

Return type:

str

call_record_method(name: str, *args, **kwargs) Any[source]
Parameters:

name (str)

Return type:

Any

property children: Iterable[EntityBase]
delete() None[source]
Return type:

None

property deleted: bool
property entity: Entity
entity_dependents: EntityDependents
entity_log: EntityLog
property entity_or_none: Entity | None
property exists: bool
classmethod get_record_type(cls: type[T], source: type[T] | None = None, **kwargs: Unpack[GetConcreteParentArgumentKwargs]) type[R]

Resolve and cache the concrete parent argument defined by the descriptor.

The descriptor caches the result per owning class via instance_lru_cache() so repeated introspections remain constant time.

Raises:

GenericsError – If the underlying parent argument cannot be resolved to a concrete type.

Parameters:
Return type:

type[R]

property in_session: bool
instance_name: str
is_reachable(*, recursive: bool = True, use_journal: bool = False) bool[source]
Parameters:
Return type:

bool

property marked_for_deletion: bool
model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': True, 'serialize_by_alias': True, 'validate_assignment': True, 'validate_by_alias': True}

Configuration for the model, should be a dictionary conforming to ConfigDict.

model_post_init(context: Any) None
Parameters:

context (Any)

Return type:

None

classmethod narrow_to_instance(value: Self | T_Record | Uid) Self[source]
Parameters:

value (Self | T_Record | Uid)

Return type:

Self

classmethod narrow_to_instance_or_none(value: Self | T_Record | Uid) Self | None[source]
Parameters:

value (Self | T_Record | Uid)

Return type:

Self | None

classmethod narrow_to_uid(value: Self | T_Record | Uid) Uid[source]
Parameters:

value (Self | T_Record | Uid)

Return type:

Uid

on_delete_record() None[source]
Return type:

None

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

record (T_Record)

Return type:

None

property record: T_Record
property record_or_none: T_Record | 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
sort_key() SupportsRichComparison[source]
Return type:

SupportsRichComparison

property superseded: bool
property superseding: Self | None
uid: Uid
classmethod uid_namespace() str[source]

Return the namespace for the UID.

This can be overridden in subclasses to provide a custom namespace.

Return type:

str

update(**kwargs) Self[source]
Return type:

Self

property version: int