class cubicweb.web.views.urlrewrite.URLRewriter(req, **extra)[source]#

Bases: cubicweb.appobject.AppObject

Base class for URL rewriters.

Url rewriters should have a rules dict that maps an input URI to something that should be used for rewriting.

The actual logic that defines how the rules dict is used is implemented in the rewrite method.

A priority attribute might be used to indicate which rewriter should be tried first. The higher the priority is, the earlier the rewriter will be tried.

class cubicweb.web.views.urlrewrite.SimpleReqRewriter(req, **extra)[source]#

Bases: cubicweb_web.views.urlrewrite.URLRewriter

The SimpleReqRewriters uses a rules dict that maps input URI (regexp or plain string) to a dictionary to update the request’s form.

If the input uri is a regexp, group substitution is allowed.

rewrite(req, uri)[source]#

for each input, output `in rules, if `uri matches input, req’s form is updated with output

class cubicweb.web.views.urlrewrite.SchemaBasedRewriter(req, **extra)[source]#

Bases: cubicweb_web.views.urlrewrite.URLRewriter

Here, the rules dict maps regexps or plain strings to callbacks that will be called with inputurl, uri, req, schema as parameters.