class documentation

class Router(object):

View In Hierarchy

A Router is an ordered collection of route->target pairs. It is used to efficiently match WSGI requests against a number of routes and return the first target that satisfies the request. The target may be anything, usually a string, ID or callable object. A route consists of a path-rule and a HTTP method.

The path-rule is either a static path (e.g. /contact) or a dynamic path that contains wildcards (e.g. /wiki/). The wildcard syntax and details on the matching order are described in docs:routing.

Method __init__ Undocumented
Method ​_compile Undocumented
Method ​_itertokens Undocumented
Method add Add a new rule or replace the target for an existing rule.
Method add​_filter Add a filter. The provided function is called with the configuration string as parameter and must return a (regexp, to_python, to_url) tuple. The first element is a string, the last two are callables or None.
Method build Build an URL by filling the wildcards in a rule.
Method match Return a (target, url_agrs) tuple or raise HTTPError(400/404/405).
Constant ​_MAX​_GROUPS​_PER​_PATTERN Undocumented
Class Variable default​_filter Undocumented
Class Variable default​_pattern Undocumented
Class Variable rule​_syntax Undocumented
Instance Variable ​_groups Undocumented
Instance Variable builder Undocumented
Instance Variable dyna​_regexes Undocumented
Instance Variable dyna​_routes Undocumented
Instance Variable filters Undocumented
Instance Variable rules Undocumented
Instance Variable static Undocumented
Instance Variable strict​_order Undocumented
def __init__(self, strict=False):

Undocumented

def _compile(self, method):

Undocumented

def _itertokens(self, rule):

Undocumented

def add(self, rule, method, target, name=None):
Add a new rule or replace the target for an existing rule.
def add_filter(self, name, func):
Add a filter. The provided function is called with the configuration string as parameter and must return a (regexp, to_python, to_url) tuple. The first element is a string, the last two are callables or None.
def build(self, _name, *anons, **query):
Build an URL by filling the wildcards in a rule.
def match(self, environ):
Return a (target, url_agrs) tuple or raise HTTPError(400/404/405).
_MAX_GROUPS_PER_PATTERN: int =

Undocumented

Value
99
default_filter: str =

Undocumented

default_pattern: str =

Undocumented

rule_syntax =

Undocumented

_groups: dict =

Undocumented

builder: dict =

Undocumented

dyna_regexes: dict =

Undocumented

dyna_routes: dict =

Undocumented

filters =

Undocumented

rules: list =

Undocumented

static: dict =

Undocumented

strict_order =

Undocumented