Presence role plugins - Betty documentation

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

# Presence role plugins

Type | `betty.ancestry.presence_role.PresenceRole`
Repository | `betty.ancestry.presence_role.PRESENCE_ROLE_REPOSITORY`

Presence roles are used to indicate the role a Person has in an Event, such as the subject, a witness, or an officiant.

## Creating a presence role

1. Create a new class that extends `betty.ancestry.presence_role.PresenceRole` and implements the abstract methods, for example:

       from typing import override
       from betty.ancestry.presence_role import PresenceRole

       class MyPresenceRole(PresenceRole):
         @override
         @classmethod
         def plugin_id(cls) -> str:
             return "my-module-my-presence-role"

         # Implement remaining abstract methods...
         ...

2. Tell Betty about your presence role by registering it as an entry point. Given the role above in a module `my_package.my_module`, add the following to your Python package:

pyproject.toml

    [project.entry-points.'betty.presence_role']
    'my-module-my-presence-role' = 'my_package.my_module.MyPresenceRole'

setup.py

    SETUP = {
        'entry_points': {
            'betty.presence_role': [
                'my-module-my-presence-role=my_package.my_module.MyPresenceRole',
            ],
        },
    }
    if __name__ == '__main__':
        setup(**SETUP)

## See also

Read more about how to use roles and Betty’s built-in presence roles at Presence Role.