trilium_alchemy.core.entity
¶
Class index¶
Canonical
Base class for Trilium entities. |
|
Entity state. Maintained automatically based on the user’s updates and object’s current state in Trilium. |
|
Accessor for read-only entity id. |
|
Accessor for a model field, e.g. a |
|
Accessor for a read-only model field, e.g. a |
|
Accessor for read-only class attribute. |
|
Accessor for class attribute which immediately populates the underlying model field when updated. |
|
Accessor for field which is only allowed a single value. Subsequent assignments are a no-op if they set the same value. |
|
Accessor for model extension. |
Symbols¶
- class trilium_alchemy.core.entity.BaseEntity(*, entity_id: str | None = None, session: Session | None = None, model_backing: ModelT | None = None, create: bool | None = None)¶
Bases:
abc.ABC
trilium_alchemy.core.session.SessionContainer
trilium_alchemy.core.entity.model.ModelContainer
Aliases:
trilium_alchemy.BaseEntity
trilium_alchemy.core.BaseEntity
Base class for Trilium entities.
Should not be instantiated by user, but published for reference.
- property str_summary: str¶
Get a summary of this entity, including its current state and model values.
- flush()¶
Commit changes to Trilium for this entity and its dependencies.
- invalidate()¶
Discard cached contents and user-provided data for this object. Upon next access, data will be fetched from Trilium.
- delete()¶
Mark this entity for pending delete.
- refresh()¶
Update value from Trilium, discarding any local changes.
- class trilium_alchemy.core.entity.State(*args, **kwds)¶
Bases:
Aliases:
trilium_alchemy.State
trilium_alchemy.core.State
Entity state. Maintained automatically based on the user’s updates and object’s current state in Trilium.
For example, state will change from
State.UPDATE
back toState.CLEAN
if the user reverts changes.- CLEAN¶
No pending changes
- CREATE¶
Pending create
- UPDATE¶
Pending update
- DELETE¶
Pending delete
- class trilium_alchemy.core.entity.EntityIdDescriptor¶
Accessor for read-only entity id.
- Raises:
ReadOnlyError – Upon write attempt
- class trilium_alchemy.core.entity.FieldDescriptor(field: str)¶
Accessor for a model field, e.g. a
Note
’stitle
field.When written, updates the working state which will be committed to Trilium upon flush. When read, returns the working state if set by user, or the state from Trilium if not.
- class trilium_alchemy.core.entity.ReadOnlyFieldDescriptor(field: str)¶
Bases:
trilium_alchemy.core.entity.FieldDescriptor
Accessor for a read-only model field, e.g. a
Note
’sdate_created
field.- Raises:
ReadOnlyError – Upon write attempt
- class trilium_alchemy.core.entity.ReadOnlyDescriptor(attr: str, allow_none_cb: str | None = None, allow_none: bool = False)¶
Accessor for read-only class attribute.
- Raises:
ReadOnlyError – Upon write attempt
- class trilium_alchemy.core.entity.WriteThroughDescriptor(attr: str, attr_attr: str, field: str)¶
Accessor for class attribute which immediately populates the underlying model field when updated.
- class trilium_alchemy.core.entity.WriteOnceDescriptor(attr: str, validator: Callable = None)¶
Accessor for field which is only allowed a single value. Subsequent assignments are a no-op if they set the same value.
- Raises:
ReadOnlyError – Upon write attempt with different value than currently set
- class trilium_alchemy.core.entity.ExtensionDescriptor(attr: str)¶
Accessor for model extension.
A model extension performs additional processing on the model and provides an interface to update other entities associated with this entity. For example,
Note
uses an extension to process the list of attributes from the note model and createBaseAttribute
instances.