betty.project.url module - Betty documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.project.url module

URL generators for project resources.

final class betty.project.url.LocalizedUrlGenerator

  Bases: `LocalizedUrlGenerator`, `ProjectDependentFactory`

  Generate URLs for all resources provided by a Betty project.

  __init__(*upstreams: LocalizedUrlGenerator)

    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

    Generate a localized URL for a localizable resource.

    Raises:

      UnsupportedResource –

  async classmethod new_for_project(project: Project) → Self

    Create a new instance using the given project.

  supports(resource: Any) → bool

    Whether the given resource is supported by this URL generator.

final class betty.project.url.StaticUrlGenerator

  Bases: `ProjectDependentFactory`, `_ProjectUrlGenerator`, `StaticUrlGenerator`

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

  generate(resource: Any, *, absolute: bool = False) → str

    Generate a static URL for a static resource.

    Raises:

      UnsupportedResource –

  async classmethod new_for_project(project: Project) → Self

    Create a new instance using the given project.

  supports(resource: Any) → bool

    Whether the given resource is supported by this URL generator.