betty.model package - Betty documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.model package

## Submodules

- betty.model.association module
  - `AssociationRegistry`
    - `AssociationRegistry.get_all_associations()`
    - `AssociationRegistry.get_association()`
  - `AssociationRequired`
    - `AssociationRequired.new()`
  - `BidirectionalToMany`
  - `BidirectionalToOne`
    - `BidirectionalToOne.resolve()`
  - `BidirectionalToZeroOrOne`
    - `BidirectionalToZeroOrOne.resolve()`
  - `TemporaryToManyResolver`
  - `TemporaryToOneResolver`
  - `TemporaryToZeroOrOneResolver`
  - `ToManyResolver`
  - `ToOneResolver`
  - `ToZeroOrOneResolver`
  - `UnidirectionalToMany`
  - `UnidirectionalToOne`
    - `UnidirectionalToOne.resolve()`
  - `UnidirectionalToZeroOrOne`
    - `UnidirectionalToZeroOrOne.resolve()`
  - `resolve()`
- betty.model.collections module
  - `EntityCollection`
    - `EntityCollection.__init__()`
    - `EntityCollection.add()`
    - `EntityCollection.clear()`
    - `EntityCollection.remove()`
    - `EntityCollection.replace()`
    - `EntityCollection.view`
  - `MultipleTypesEntityCollection`
    - `MultipleTypesEntityCollection.__init__()`
    - `MultipleTypesEntityCollection.add()`
    - `MultipleTypesEntityCollection.clear()`
    - `MultipleTypesEntityCollection.new()`
    - `MultipleTypesEntityCollection.remove()`
  - `SingleTypeEntityCollection`
    - `SingleTypeEntityCollection.__init__()`
    - `SingleTypeEntityCollection.add()`
    - `SingleTypeEntityCollection.clear()`
    - `SingleTypeEntityCollection.remove()`
  - `record_added()`
- betty.model.config module
  - `EntityReference`
    - `EntityReference.__init__()`
    - `EntityReference.dump()`
    - `EntityReference.entity_id`
    - `EntityReference.entity_type`
    - `EntityReference.entity_type_is_constrained`
    - `EntityReference.load()`
    - `EntityReference.validate()`
  - `EntityReferenceSequence`
    - `EntityReferenceSequence.__init__()`
    - `EntityReferenceSequence.validate()`

## Module contents

Provide Betty’s data model API.

betty.model.ENTITY_TYPE_REPOSITORY: PluginRepository[Entity] = <betty.plugin.entry_point.EntryPointPluginRepository object>

  The entity type plugin repository.

  Read more about Entity type plugins.

class betty.model.Entity

  Bases: `LinkedDataDumpableJsonLdObject`, `Plugin`

  An entity is a uniquely identifiable data container.

  Read more about Entity type plugins.

  To test your own subclasses, use `betty.test_utils.model.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) → DumpMapping[Dump]

    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.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

  abstractmethod classmethod plugin_label_plural() → Localizable

    The human-readable entity type label, plural.

  property type: builtins.type[Self]

    The entity type.

class betty.model.EntityReferenceCollectionSchema

  Bases: `Array`

  A schema for a collection of references to other entity resources.

  __init__(*, title: str | None = None, description: str | None = None)

class betty.model.EntityReferenceSchema

  Bases: `String`

  A schema for a reference to another entity resource.

  __init__(*, title: str | None = None, description: str | None = None)

class betty.model.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)

class betty.model.UserFacingEntity

  Bases: `object`

  A sentinel to mark an entity type as being visible to users (e.g. not internal).

betty.model.persistent_id(entity_or_id: Entity | str) → bool

  Test if an entity ID is persistent.

  See `betty.model.NonPersistentId`.