web_urldispatcher

Module Contents

Classes

AbstractResource(self)
AbstractRoute(self,method,handler)
UrlMappingMatchInfo(self,match_dict,route)
MatchInfoError(self,http_exception)
Resource(self)
PlainResource(self,path)
DynamicResource(self,path)
PrefixResource(self,prefix)
StaticResource(self,prefix,directory)
PrefixedSubAppResource(self,prefix,app)
ResourceRoute(self,method,handler,resource) A route with resource
SystemRoute(self,http_exception)
View()
ResourcesView(self,resources)
RoutesView(self,resources)
UrlDispatcher(self)

Functions

_default_expect_handler(request) Default handler for Expect header.
class AbstractResource
__init__()
name()
canonical()

Exposes the resource’s canonical path.

For example ‘/foo/bar/{name}’

url_for(**kwargs)

Construct url for resource with additional params.

resolve(request)

Resolve resource

Return (UrlMappingMatchInfo, allowed_methods) pair.

add_prefix(prefix)

Add a prefix to processed URLs.

Required for subapplications support.

get_info()

Return a dict with additional info useful for introspection

freeze()
raw_match(path)

Perform a raw match against path

class AbstractRoute(method, handler)
__init__(method, handler)
method()
handler()
name()

Optional route’s name, always equals to resource’s name.

resource()
get_info()

Return a dict with additional info useful for introspection

url_for(*args, **kwargs)

Construct url for route with additional params.

handle_expect_header(request)
class UrlMappingMatchInfo(match_dict, route)
__init__(match_dict, route)
handler()
route()
expect_handler()
http_exception()
get_info()
apps()
add_app(app)
current_app()
set_current_app(app)
freeze()
__repr__()
class MatchInfoError(http_exception)
__init__(http_exception)
http_exception()
__repr__()
_default_expect_handler(request)

Default handler for Expect header.

Just send “100 Continue” to client. raise HTTPExpectationFailed if value of header is not “100-continue”

class Resource
__init__()
add_route(method, handler)
register_route(route)
resolve(request)
__len__()
__iter__()
class PlainResource(path)
__init__(path)
canonical()
freeze()
add_prefix(prefix)
_match(path)
raw_match(path)
get_info()
url_for()
__repr__()
class DynamicResource(path)
__init__(path)
canonical()
add_prefix(prefix)
_match(path)
raw_match(path)
get_info()
url_for(**parts)
__repr__()
class PrefixResource(prefix)
__init__(prefix)
canonical()
add_prefix(prefix)
raw_match(prefix)
class StaticResource(prefix, directory)
__init__(prefix, directory)
url_for()
_get_file_hash()
get_info()
set_options_route(handler)
resolve(request)
__len__()
__iter__()
_handle(request)
_directory_as_html(filepath)
__repr__()
class PrefixedSubAppResource(prefix, app)
__init__(prefix, app)
add_prefix(prefix)
url_for(*args, **kwargs)
get_info()
resolve(request)
__len__()
__iter__()
__repr__()
class ResourceRoute(method, handler, resource)

A route with resource

__init__(method, handler, resource)
__repr__()
name()
url_for(*args, **kwargs)

Construct url for route with additional params.

get_info()
class SystemRoute(http_exception)
__init__(http_exception)
url_for(*args, **kwargs)
name()
get_info()
_handler(request)
status()
reason()
__repr__()
class View
_iter()
__await__()
_raise_allowed_methods()
class ResourcesView(resources)
__init__(resources)
__len__()
__iter__()
__contains__(resource)
class RoutesView(resources)
__init__(resources)
__len__()
__iter__()
__contains__(route_obj)
class UrlDispatcher
__init__()
resolve(request)
__iter__()
__len__()
__contains__(name)
__getitem__(name)
resources()
routes()
named_resources()
register_resource(resource)
add_resource(path)
add_route(method, path, handler)
add_static(prefix, path)

Add static files view.

prefix - url prefix path - folder with files

add_head(path, handler, **kwargs)

Shortcut for add_route with method HEAD

add_get(path, handler, **kwargs)

Shortcut for add_route with method GET, if allow_head is true another route is added allowing head requests to the same endpoint

add_post(path, handler, **kwargs)

Shortcut for add_route with method POST

add_put(path, handler, **kwargs)

Shortcut for add_route with method PUT

add_patch(path, handler, **kwargs)

Shortcut for add_route with method PATCH

add_delete(path, handler, **kwargs)

Shortcut for add_route with method DELETE

add_view(path, handler, **kwargs)

Shortcut for add_route with ANY methods for a class-based view

freeze()
add_routes(routes)

Append routes to route table.

Parameter should be a sequence of RouteDef objects.