Place type 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

# Place type plugins

Type | `betty.ancestry.place_type.PlaceType`
Repository | `betty.project.Project.place_type_repository`

Place types are used to indicate the type of a Place, such as a country, a city, or a house number.

## Creating a place type

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

       from typing import override
       from betty.ancestry.place_type import PlaceType
       from betty.machine_name import MachineName

       class MyPlaceType(PlaceType):
         @override
         @classmethod
         def plugin_id(cls) -> MachineName:
             return "my-module-my-place-type"

         # Implement remaining abstract methods...
         ...

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

pyproject.toml

    [project.entry-points.'betty.place_type']
    'my-module-my-place-type' = 'my_package.my_module.MyPlaceType'

setup.py

    SETUP = {
        'entry_points': {
            'betty.place_type': [
                'my-module-my-place-type=my_package.my_module.MyPlaceType',
            ],
        },
    }
    if __name__ == '__main__':
        setup(**SETUP)

## See also

Read more about how to use place types and Betty’s built-in place types at Place Type.