betty.url module

Provide a URL generation API.

class betty.url.AppUrlGenerator[source]

Bases: LocalizedUrlGenerator

Generate URLs for all resources provided by a Betty application.

Parameters:

app (betty.app.App)

__init__(app: betty.app.App)[source]
Parameters:

app (betty.app.App)

generate(resource: Any, media_type: str, absolute: bool = False, locale: str | babel.core.Locale | None = None) str[source]

Generate a URL for a resource.

Parameters:
Return type:

str

class betty.url.LocalizedPathUrlGenerator[source]

Bases: LocalizedUrlGenerator

Generate URLs for localizable file paths.

Parameters:

app (betty.app.App)

__init__(app: betty.app.App)[source]
Parameters:

app (betty.app.App)

generate(resource: Any, media_type: str, absolute: bool = False, locale: str | babel.core.Locale | None = None) str[source]

Generate a URL for a resource.

Parameters:
Return type:

str

class betty.url.LocalizedUrlGenerator[source]

Bases: object

Generate URLs for localizable resources.

generate(resource: Any, media_type: str, absolute: bool = False, locale: str | babel.core.Locale | None = None) str[source]

Generate a URL for a resource.

Parameters:
Return type:

str

class betty.url.StaticPathUrlGenerator[source]

Bases: StaticUrlGenerator

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

Parameters:

configuration (betty.project.ProjectConfiguration)

__init__(configuration: betty.project.ProjectConfiguration)[source]
Parameters:

configuration (betty.project.ProjectConfiguration)

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

Generate a URL for a resource.

Parameters:
Return type:

str

class betty.url.StaticUrlGenerator[source]

Bases: object

Generate URLs for static (non-localizable) resources.

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

Generate a URL for a resource.

Parameters:
Return type:

str