Extension URLs¤
Overview of all classes, functions, and other objects related to defining extension URLs.
Read more on Extensions.
URLRoute dataclass
¤
URLRoute(
path: str,
handler: Optional[URLRouteHandler] = None,
children: Iterable[URLRoute] = list(),
name: Optional[str] = None,
extra: Dict[str, Any] = dict(),
)
Bases: object
Framework-agnostic route definition.
This is similar to Django's URLPattern
object created with django.urls.path()
.
The URLRoute
must either define a handler
function or have a list of child routes children
. If both are defined, an error will be raised.
Example:
URLRoute("/my/path", handler=my_handler, name="my_name", extra={"kwargs": {"my_extra": "my_value"}})
Is equivalent to:
With children:
URLRoute(
"/my/path",
name="my_name",
extra={"kwargs": {"my_extra": "my_value"}},
children=[
URLRoute(
"/child/<str:name>/",
handler=my_handler,
name="my_name",
extra={"kwargs": {"my_extra": "my_value"}},
),
URLRoute("/other/<int:id>/", handler=other_handler),
],
)
Attributes:
-
children
(Iterable[URLRoute]
) – -
extra
(Dict[str, Any]
) – -
handler
(Optional[URLRouteHandler]
) – -
name
(Optional[str]
) – -
path
(str
) –