betty.url package - 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.url package

## Submodules

- betty.url.proxy module
  - `ProxyLocalizedUrlGenerator`
    - `ProxyLocalizedUrlGenerator.__init__()`
    - `ProxyLocalizedUrlGenerator.generate()`
    - `ProxyLocalizedUrlGenerator.supports()`

## Module contents

Provide a URL generation API.

class betty.url.LocalizedUrlGenerator

  Bases: `_UrlGenerator`

  Generate URLs for localizable resources.

  abstract generate(resource: Any, media_type: MediaType, *, absolute: bool = False, locale: Localey | None = None) → str

    Generate a localized URL for a localizable resource.

    Raises:

      UnsupportedResource –

class betty.url.StaticUrlGenerator

  Bases: `_UrlGenerator`

  Generate URLs for static (non-localizable) resources.

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

    Generate a static URL for a static resource.

    Raises:

      UnsupportedResource –

exception betty.url.UnsupportedResource

  Bases: `RuntimeError`

  Raised when a URL generator cannot generate a URL for a resource.

  These are preventable by checking `betty.url.LocalizedUrlGenerator.supports()` or `betty.url.StaticUrlGenerator.supports()` first.

  classmethod new(resource: Any) → Self

    Create a new instance.

betty.url.generate_from_path(path: str, *, base_url: str, root_path: str, locales: Mapping[str, str], clean_urls: bool, absolute: bool = False, locale: Localey | None = None) → str

  Generate a full URL from a public path.