betty.app module - Betty 0.4.0a3 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 module

Define Betty’s core application functionality.

final class betty.app.App

  Bases: `Configurable`[`AppConfiguration`], `CoreComponent`

  The Betty application.

  Parameters:

    - configuration (`betty.app.AppConfiguration`)

    - cache_directory_path (`pathlib.Path`)

    - cache_factory (`collections.abc.Callable`[[`typing.Self`], `betty.cache.Cache`[`typing.Any`]])

  __init__(configuration: betty.app.AppConfiguration, cache_directory_path: pathlib.Path, *, cache_factory: collections.abc.Callable[[Self], betty.cache.Cache[Any]])
    Parameters:

      - configuration (`betty.app.AppConfiguration`)

      - cache_directory_path (`pathlib.Path`)

      - cache_factory (`collections.abc.Callable`[[`typing.Self`], `betty.cache.Cache`[`typing.Any`]])

  property assets: AssetRepository

    The assets file system.

  property binary_file_cache: BinaryFileCache

    The binary file cache.

  property cache: Cache[Any]

    The cache.

  property fetcher: Fetcher

    The fetcher.

  property http_client: ClientSession

    The HTTP client.

  property localizer: Localizer

    Get the application’s localizer.

  property localizers: LocalizerRepository

    The available localizers.

  classmethod new_from_environment(cls) → collections.abc.AsyncIterator[Self]

    Create a new application from the environment.

    Return type:

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

  classmethod new_temporary(cls) → 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.

    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.

final class betty.app.AppConfiguration

  Bases: `Configuration`

  Provide configuration for `betty.app.App`.

  Parameters:

    locale (`str` | `None`)

  __init__(*, locale: str | None = None)
    Parameters:

      locale (`str` | `None`)

  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.typing.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.typing.Void`]]

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

    Load dumped configuration.

    Raises:

      betty.assertion.error.AssertionFailed – Raised if the dump contains invalid 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`