betty.app package

Submodules

Module contents

Define Betty’s core application functionality.

final class betty.app.App[source]

Bases: Configurable[AppConfiguration], TargetFactory, CoreComponent

The Betty application.

__init__(configuration: AppConfiguration, cache_directory_path: Path, *, cache_factory: Callable[[Self], Cache[Any]], fetcher: Fetcher | None = None)[source]
property assets: AssetRepository

The assets file system.

property binary_file_cache: BinaryFileCache

The binary file cache.

property cache: Cache[Any]

The cache.

property fetcher: Awaitable[Fetcher]

The fetcher.

property http_client: Awaitable[aiohttp.ClientSession]

The HTTP client.

property localizer: Awaitable[Localizer]

Get the application’s localizer.

property localizers: LocalizerRepository

The available localizers.

classmethod new_from_environment() AsyncIterator[Self][source]

Create a new application from the environment.

async new_target(cls: type[_T]) _T[source]

Create a new instance.

Returns:

  1. If cls extends betty.app.factory.AppDependentFactory, this will call return cls’s

    new()’s return value.

  2. If cls extends betty.factory.IndependentFactory, this will call return cls’s

    new()’s return value.

  3. Otherwise cls() will be called without arguments, and the resulting instance will be returned.

Raises:

FactoryError – raised when cls could not be instantiated.

classmethod new_temporary(*, fetcher: Fetcher | None = None) AsyncIterator[Self][source]

Creat a new, temporary, isolated application.

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

property process_pool: Executor

The shared process pool.

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

property spdx_license_repository: Awaitable[PluginRepository[License]]

The SPDX licenses available to this application.