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.

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

Generate a URL for a resource.

Raises:
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: _ProjectUrlGenerator, StaticUrlGenerator

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

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

Generate a static URL for a static resource.

Raises:
supports(resource: Any) bool[source]

Whether the given resource is supported by this URL generator.

async betty.project.url.new_project_url_generator(project: Project) UrlGenerator[source]

Generate URLs for all resources provided by a Betty project.