betty.project package

Subpackages

Submodules

Module contents

Provide the project API.

Projects are how people use Betty. A project is a workspace, starting out with the user’s configuration, and combining it with the resulting ancestry, allowing the user to perform tasks, such as generating a site from the entire project.

final class betty.project.Project[source]

Bases: Configurable[ProjectConfiguration], TargetFactory, CoreComponent

Define a Betty project.

A project combines project configuration and the resulting ancestry.

__init__(app: App, configuration: ProjectConfiguration, *, ancestry: Ancestry)[source]
property ancestry: Ancestry

The project’s ancestry.

property app: App

The application this project is run within.

property assets: Awaitable[AssetRepository]

The assets file system.

async bootstrap() None[source]

Bootstrap the component.

property copyright_notice: Awaitable[CopyrightNotice]

The overall project copyright.

property copyright_notice_repository: PluginRepository[CopyrightNotice]

The copyright notices available to this project.

Read more about Copyright notice plugins.

property entity_type_repository: PluginRepository[Entity]

The entity types available to this project.

Read more about Entity type plugins.

property event_dispatcher: EventDispatcher

The event dispatcher.

property event_type_repository: PluginRepository[EventType]

The event types available to this project.

property extension_repository: PluginRepository[Extension]

The extensions available to this project.

Read more about Extension plugins.

property extensions: Awaitable[ProjectExtensions]

The enabled extensions.

property gender_repository: PluginRepository[Gender]

The genders available to this project.

Read more about Gender plugins.

property jinja2_environment: Awaitable[Environment]

The Jinja2 environment.

property license: Awaitable[License]

The overall project license.

property license_repository: Awaitable[PluginRepository[License]]

The licenses available to this project.

Read more about License plugins.

property localized_url_generator: Awaitable[LocalizedUrlGenerator]

The URL generator for localizable resources.

property localizers: Awaitable[LocalizerRepository]

The available localizers.

The path to the logo file.

property name: MachineName

The project name.

If no project name was configured, this defaults to the hash of the configuration file path.

async classmethod new(app: App, *, configuration: ProjectConfiguration, ancestry: Ancestry | None = None) Self[source]

Create a new instance.

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

Create a new instance.

Returns:

  1. If cls extends betty.project.factory.ProjectDependentFactory, this will call return

    cls’s new()’s return value.

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

    new()’s return value.

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

    new()’s return value.

  4. 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(app: App, *, configuration: ProjectConfiguration | None = None, ancestry: Ancestry | None = None) AsyncIterator[Self][source]

Creat a new, temporary, isolated project.

The project will not leave any traces on the system, except when it uses global Betty functionality such as caches.

property place_type_repository: PluginRepository[PlaceType]

The place types available to this project.

property presence_role_repository: PluginRepository[PresenceRole]

The presence roles available to this project.

property renderer: Awaitable[Renderer]

The (file) content renderer.

property static_url_generator: Awaitable[StaticUrlGenerator]

The URL generator for static resources.

class betty.project.ProjectContext[source]

Bases: Context

A job context for a project.

__init__(project: Project)[source]
property project: Project

The Betty project this job context is run within.

class betty.project.ProjectEvent[source]

Bases: Event

An event that is dispatched within the context of a betty.project.Project.

__init__(job_context: ProjectContext)[source]
property job_context: ProjectContext

The site generation job context.

property project: Project

The betty.project.Project this event is dispatched within.

final class betty.project.ProjectExtensions[source]

Bases: object

Manage the extensions running within the betty.project.Project.

This is internal. It MAY be used anywhere in Betty’s source code, but MUST NOT be used by third-party code.

__init__(project_extensions: Sequence[Sequence[Extension]])[source]
flatten() Iterator[Extension][source]

Get a sequence of topologically sorted extensions.

final class betty.project.ProjectSchema[source]

Bases: ProjectDependentFactory, Schema

A JSON Schema for a project.

async classmethod def_url(project: Project, def_name: str) str[source]

Get the URL to a project’s JSON Schema definition.

async classmethod new_for_project(project: Project) Self[source]

Create a new instance using the given project.

async classmethod url(project: Project) str[source]

Get the URL to a project’s JSON Schema.

classmethod www_path(project: Project) Path[source]

Get the path to the schema file in a site’s public WWW directory.