betty.url module - Betty 0.4.0a4 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 module

Provide a URL generation API.

final class betty.url.LocalizedPathUrlGenerator

  Bases: `LocalizedUrlGenerator`

  Generate URLs for localizable file paths.

  __init__(project: Project)
  generate(resource: Any, media_type: str, absolute: bool = False, locale: str | Locale | None = None) → str

    Generate a URL for a resource.

  supports(resource: Any) → bool

    Whether the given resource is supported by this URL generator.

class betty.url.LocalizedUrlGenerator

  Bases: `_UrlGenerator`

  Generate URLs for localizable resources.

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

    Generate a URL for a resource.

final class betty.url.ProjectUrlGenerator

  Bases: `LocalizedUrlGenerator`

  Generate URLs for all resources provided by a Betty project.

  __init__(project: Project)
  generate(resource: Any, media_type: str, absolute: bool = False, locale: str | Locale | None = None) → str

    Generate a URL for a resource.

  supports(resource: Any) → bool

    Whether the given resource is supported by this URL generator.

final class betty.url.StaticPathUrlGenerator

  Bases: `StaticUrlGenerator`

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

  __init__(configuration: ProjectConfiguration)
  generate(resource: Any, absolute: bool = False) → str

    Generate a URL for a resource.

  supports(resource: Any) → bool

    Whether the given resource is supported by this URL generator.

class betty.url.StaticUrlGenerator

  Bases: `_UrlGenerator`

  Generate URLs for static (non-localizable) resources.

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

    Generate a URL for a resource.