betty.project.url module

URL generators for project resources.

final class betty.project.url.LocalizedUrlGenerator[source]

Bases: LocalizedUrlGenerator, ProjectDependentFactory

Generate URLs for all resources provided by a Betty project.

__init__(*upstreams: LocalizedUrlGenerator)[source]

This is private. It MUST NOT be used anywhere outside its containing scope.

generate(resource: Any, media_type: MediaType, *, absolute: bool = False, locale: Localey | None = None) str[source]

Generate a localized URL for a localizable resource.

Raises:

UnsupportedResource

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

Create a new instance using the given project.

supports(resource: Any) bool[source]

Whether the given resource is supported by this URL generator.

final class betty.project.url.StaticUrlGenerator[source]

Bases: ProjectDependentFactory, _ProjectUrlGenerator, StaticUrlGenerator

Generate URLs for static (non-localized) file paths.

generate(resource: Any, *, absolute: bool = False) str[source]

Generate a static URL for a static resource.

Raises:

UnsupportedResource

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

Create a new instance using the given project.

supports(resource: Any) bool[source]

Whether the given resource is supported by this URL generator.