betty.app package - Betty 0.4.0a1 documentation

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

# betty.app package

## Subpackages

- betty.app.extension package
  - Module contents
    - `ConfigurableExtension`
      - `ConfigurableExtension.__init__()`
      - `ConfigurableExtension.default_configuration()`
    - `CyclicDependencyError`
      - `CyclicDependencyError.__init__()`
    - `Dependencies`
      - `Dependencies.__init__()`
      - `Dependencies.for_dependent()`
      - `Dependencies.summary()`
    - `Dependents`
      - `Dependents.__init__()`
      - `Dependents.for_dependency()`
      - `Dependents.is_met()`
      - `Dependents.summary()`
    - `Extension`
      - `Extension.__init__()`
      - `Extension.app`
      - `Extension.assets_directory_path()`
      - `Extension.comes_after()`
      - `Extension.comes_before()`
      - `Extension.depends_on()`
      - `Extension.disable_requirement()`
      - `Extension.enable_requirement()`
      - `Extension.name()`
    - `ExtensionDispatcher`
      - `ExtensionDispatcher.__init__()`
      - `ExtensionDispatcher.dispatch()`
    - `ExtensionError`
    - `ExtensionTypeError`
    - `ExtensionTypeImportError`
      - `ExtensionTypeImportError.__init__()`
    - `ExtensionTypeInvalidError`
      - `ExtensionTypeInvalidError.__init__()`
    - `Extensions`
      - `Extensions.flatten()`
    - `ListExtensions`
      - `ListExtensions.__init__()`
      - `ListExtensions.flatten()`
    - `Theme`
    - `UserFacingExtension`
      - `UserFacingExtension.description()`
      - `UserFacingExtension.label()`
    - `build_extension_type_graph()`
    - `discover_extension_types()`
    - `format_extension_type()`
    - `get_extension_type()`
    - `get_extension_type_by_extension()`
    - `get_extension_type_by_name()`
    - `get_extension_type_by_type()`

## Module contents

Define Betty’s core application functionality.

final class betty.app.App

  Bases: `Configurable`[`AppConfiguration`]

  The Betty application.

  Parameters:

    - configuration (`betty.app.AppConfiguration`)

    - cache_directory_path (`pathlib.Path`)

    - project (`betty.project.Project` | `None`)

  __init__(configuration: betty.app.AppConfiguration, cache_directory_path: pathlib.Path, project: betty.project.Project | None = None)
    Parameters:

      - configuration (`betty.app.AppConfiguration`)

      - cache_directory_path (`pathlib.Path`)

      - project (`betty.project.Project` | `None`)

  property assets: AssetRepository

    The assets file system.

  property binary_file_cache: BinaryFileCache

    The binary file cache.

  property cache: Cache[Any]

    The cache.

  discover_extension_types() → set[type[betty.app.extension.Extension]]

    Discover the available extension types.

    Return type:

      `set`[`type`[`betty.app.extension.Extension`]]

  property dispatcher: Dispatcher

    The event dispatcher.

  property entity_types: set[type[Entity]]

    The available entity types.

  property event_types: set[type[EventType]]

    The available event types.

  property extensions: Extensions

    The enabled extensions.

  property fetcher: Fetcher

    The fetcher.

  property http_client: ClientSession

    The HTTP client.

  property jinja2_environment: Environment

    The Jinja2 environment.

  property localizer: Localizer

    Get the application’s localizer.

  property localizers: LocalizerRepository

    The available localizers.

  classmethod new_from_app(cls, app: betty.app.App, *, project: betty.project.Project | None = None) → collections.abc.AsyncIterator[Self]

    Create a new application from an existing application.

    Parameters:

      - app (`betty.app.App`)

      - project (`betty.project.Project` | `None`)

    Return type:

      `collections.abc.AsyncIterator`[`typing.Self`]

  classmethod new_from_environment(cls, *, project: betty.project.Project | None = None) → collections.abc.AsyncIterator[Self]

    Create a new application from the environment.

    Parameters:

      project (`betty.project.Project` | `None`)

    Return type:

      `collections.abc.AsyncIterator`[`typing.Self`]

  classmethod new_temporary(cls, *, project: betty.project.Project | None = None) → collections.abc.AsyncIterator[Self]

    Creat a new, temporary, isolated application.

    The application will not use any persistent caches, or leave any traces on the system.

    Parameters:

      project (`betty.project.Project` | `None`)

    Return type:

      `collections.abc.AsyncIterator`[`typing.Self`]

  property process_pool: Executor

    The shared process pool.

    Use this to run CPU/computationally-heavy tasks in other processes.

  property project: Project

    The project.

  property renderer: Renderer

    The (file) content renderer.

  async start() → None

    Start the application.

    Return type:

      `None`

  property static_url_generator: StaticUrlGenerator

    The static URL generator.

  async stop() → None

    Stop the application.

    Return type:

      `None`

  property url_generator: LocalizedUrlGenerator

    The (localized) URL generator.

class betty.app.AppConfiguration

  Bases: `FileBasedConfiguration`

  Provide configuration for `betty.app.App`.

  Parameters:

    - configuration_directory_path (`pathlib.Path` | `None`)

    - locale (`str` | `None`)

  __init__(configuration_directory_path: pathlib.Path | None = None, *, locale: str | None = None)
    Parameters:

      - configuration_directory_path (`pathlib.Path` | `None`)

      - locale (`str` | `None`)

  property configuration_file_path: Path

    The path to the configuration’s file.

  dump() → bool | int | float | str | None | Sequence[bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | Mapping[str, bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]] | type[betty.serde.dump.Void]

    Dump this instance to a portable format.

    Return type:

      `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `typing.Mapping`[`str`, `typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]]], `type`[`betty.serde.dump.Void`]]

  load(dump: bool | int | float | str | None | Sequence[Dump] | Mapping[str, Dump]) → None

    Load dumped configuration.

    Parameters:

      dump (`typing.Union`[`bool`, `int`, `float`, `str`, `None`, `typing.Sequence`[Dump], `typing.Mapping`[`str`, Dump]])

    Return type:

      `None`

  property locale: str | None

    The application locale.

  update(other: Self) → None

    Update this configuration with the values from `other`.

    Parameters:

      other (`typing.Self`)

    Return type:

      `None`