labapi.entry.entries.base.Entry#
- class labapi.entry.entries.base.Entry(
- eid: str,
- data: str,
- user: User,
- *,
- created_at: datetime | None = None,
- updated_at: datetime | None = None,
- version: int | None = None,
-
Abstract base class for all entry types on a LabArchives page.
This class provides a common interface for different entry types such as text entries, headers, attachments, and widgets. It uses a generic type parameter T to represent the content type of the entry.
LabArchives does not currently expose an API endpoint for deleting individual entries, so this class intentionally does not provide a
delete()method.- Parameters:
T – The type of content stored in the entry (e.g., str for text, Attachment for files).
- __init__(
- eid: str,
- data: str,
- user: User,
- *,
- created_at: datetime | None = None,
- updated_at: datetime | None = None,
- version: int | None = None,
Initialize an entry.
- Parameters:
eid – The unique ID of the entry.
data – The entry data or attachment caption.
user – The authenticated user associated with this entry.
created_at – When the entry was created, if supplied by the API.
updated_at – When the entry was last updated, if supplied by the API.
version – The entry’s API version number, if supplied by the API.
Methods
__init__(eid, data, user, *[, created_at, ...])Initialize an entry.
class_of(part_type)Return the registered entry class for
part_type.from_part_type(part_type, eid, data, user, *)Create an entry instance for a LabArchives part type.
is_registered(part_type)Return whether an entry class is registered for
part_type.Attributes
Return the entry content.
Return the LabArchives content type identifier for this entry.
Return when this entry was created, if supplied by the API.
Return the unique identifier of the entry.
Return when this entry was last updated, if supplied by the API.
Return this entry's API version number, if supplied by the API.
- static is_registered(part_type: str) bool[source]#
Return whether an entry class is registered for
part_type.- Parameters:
part_type – The LabArchives part type identifier to check.
- Returns:
True if a class is registered for this part type, False otherwise.
- static class_of(
- part_type: str,
Return the registered entry class for
part_type.
- static from_part_type(
- part_type: str,
- eid: str,
- data: str,
- user: User,
- *,
- created_at: datetime | None = None,
- updated_at: datetime | None = None,
- version: int | None = None,
Create an entry instance for a LabArchives part type.
This method takes a part type string and returns the corresponding entry class instance when one is registered. Recognized-but-unimplemented part types resolve to
UnimplementedEntry, while truly unknown part types fall back toUnknownEntry.- Parameters:
part_type – The type of entry to create (e.g., “heading”, “text entry”, “plain text entry”, “attachment”, “widget entry”).
eid – The unique ID of the entry.
data – The entry data. For text-based entries, this is the text content. For attachment entries, this is the caption.
user – The authenticated user associated with this entry.
created_at – When the entry was created, if supplied by the API.
updated_at – When the entry was last updated, if supplied by the API.
version – The entry’s API version number, if supplied by the API.
- Returns:
An entry instance of the appropriate type.
- property content_type: str#
Return the LabArchives content type identifier for this entry.
- Returns:
A string representing the entry’s type (e.g., “text entry”, “Attachment”).
- property updated_at: datetime | None#
Return when this entry was last updated, if supplied by the API.
- abstract property content: T#
Return the entry content.
The specific type of the content depends on the entry type (e.g., string for text entries,
Attachmentfor attachments).- Returns:
The content of the entry.