betty.entity package

Subpackages

Submodules

Module contents

Provide Betty’s data model API.

class betty.entity.Entity

Bases: LinkedDataDumpableWithSchemaJsonLdObject, Plugin[EntityDefinition], HasProps

An entity is a uniquely identifiable data container.

To test your own subclasses, use betty.test_utils.entity.EntityTestBase.

__init__(id: str | None = None, *args: Any, **kwargs: Any)
property ancestry_id: tuple[builtins.type[Self], str]

The ancestry ID.

This MUST be unique per ancestry.

async dump_linked_data(project: Project, /) PortableMapping

Dump this instance to JSON-LD.

property id: str

The entity ID.

This MUST be unique per entity type, per ancestry.

property label: Localizable

The entity’s human-readable label.

async classmethod linked_data_schema(project: Project, /) JsonLdObject

Define the JSON Schema for betty.linked_data.LinkedDataDumpable.dump_linked_data().

property public_id: str

The public entity ID.

This MUST be unique per entity type, per ancestry.

A public ID consists of alphanumeric characters only, and can therefore safely be used across file systems.

final class betty.entity.EntityDefinition

Bases: CountableHumanFacingDefinition, PluginClsDefinition[Entity]

The entity plugin type. Entities represent the information in your ancestry, such as people and places.

Plugin type ID

entity

Definition

@EntityDefinition(...)

Built-in entities:

citation (Citation)
Citation
enclosure (Enclosure)
Enclosure
event (Event)
Event
file (File)
File
file-reference (FileReference)
File reference
link (Link)
Link
note (Note)
Note
person (Person)
Person
person-name (PersonName)
Person name
place (Place)
Place
place-name (PlaceName)
Place name
presence (Presence)
Presence: A person's presence at an event.
source (Source)
Source
__init__(plugin_id: ResolvableMachineName, *, label: ResolvableLocalizable, label_plural: ResolvableLocalizable, label_countable: CountableLocalizable, auto: bool = True, description: ResolvableLocalizable | None = None, public_facing: bool = True, requires: Requires = ())
property public_facing: bool

Whether entities of this type are public-facing.

static type() PluginTypeDefinition[Self]

The plugin type definition.

class betty.entity.NonPersistentId

Bases: str

A randomly generated ID that is not persistent.

Entities must have IDs for identification. However, not all entities can be provided with an ID that exists in the original data set (such as a third-party family tree loaded into Betty).

Non-persistent IDs are helpful in case there is no external ID that can be used. However, as they do not persist when reloading an ancestry, they MUST NOT be in contexts where persistent identifiers are expected, such as in URLs.

static __new__(cls, entity_id: str | None = None, /)
betty.entity.persistent_id(entity_or_id: Entity | str, /) bool

Test if an entity ID is persistent.

See betty.entity.NonPersistentId.