labapi.entry.collection.Entries#

class labapi.entry.collection.Entries(
entries: Sequence[Entry[Any]],
user: User,
page: NotebookPage,
)[source]#

Bases: Sequence[Entry[Any]]

A collection of entries on a LabArchives page.

This class provides a sequence-like interface for managing entries within a page, including a generic method for creating new entries by class.

__init__(
entries: Sequence[Entry[Any]],
user: User,
page: NotebookPage,
)[source]#

Initialize an entries collection.

Parameters:
  • entries – A sequence of Entry objects.

  • user – The authenticated user.

  • page – The page that this collection belongs to.

Methods

__init__(entries, user, page)

Initialize an entries collection.

count(value)

create()

Create a new entry on the page.

create_json_entry(data, *[, filename, caption])

Create a JSON attachment plus a companion reference text entry.

index(value, [start, [stop]])

Raises ValueError if the value is not present.

count(
value,
) integer -- return number of occurrences of value#
index(
value[,
start[,
stop,]]
) integer -- return first index of value.#

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

create_json_entry(
data: JsonData,
*,
filename: str | None = None,
caption: str | None = None,
) tuple[AttachmentEntry, TextEntry][source]#

Create a JSON attachment plus a companion reference text entry.

This method uploads JSON data as an attachment file and creates a companion text entry that references the attachment and displays a formatted preview of the JSON data.

Parameters:
  • data – The JSON-serializable data to upload.

  • filename – Optional stable filename for the uploaded JSON attachment.

  • caption – Optional label/caption for the generated attachment and reference entry.

Returns:

A tuple containing the attachment entry and the text entry.

create(
cls: type[AttachmentEntry],
data: Attachment,
*,
client_ip: str | None = None,
) AttachmentEntry[source]#
create(
cls: type[E],
data: str,
*,
client_ip: str | None = None,
) E

Create a new entry on the page.

This method supports creating any entry type by passing the entry class directly, similar to create(). The created entry is automatically added to the collection.

Parameters:
  • cls – The entry class to create (e.g., TextEntry, HeaderEntry, AttachmentEntry).

  • data – The content of the entry. For text-based entries, this should be a string. For AttachmentEntry, this should be an Attachment object.

  • client_ip – Optional end-user IP to pass through on attachment uploads.

Returns:

The newly created entry object of the specified type.

Raises:

RuntimeError – If the API call to create the entry fails.