Associate url’s path to view identifier / rql queries.
CubicWeb finds all registered URLPathEvaluators, orders them according
priority attribute and calls their
method. The first that returns something and doesn’t raise a
PathDontMatch exception wins.
Here is the default evaluator chain:
cubicweb.web.views.urlpublishing.RawPathEvaluatorhandles unique url segments that match exactly one of the registered controller’s __regid__. Urls such as /view?, /edit?, /json? fall in that category;
cubicweb.web.views.urlpublishing.EidPathEvaluatorhandles unique url segments that are eids (e.g. /1234);
cubicweb.web.views.urlpublishing.URLRewriteEvaluatorselects all urlrewriter components, sorts them according to their priority, call their
rewrite()method, the first one that doesn’t raise a
KeyErrorwins. This is where the
cubicweb.web.views.urlrewrite.SimpleReqRewritercomes into play;
cubicweb.web.views.urlpublishing.RestPathEvaluatorhandles urls based on entity types and attributes : <etype>((/<attribute name>])?/<attribute value>)? This is why
cubicweb.web.views.urlpublishing.ActionPathEvaluatorhandles any of the previous paths with an additional trailing “/<action>” segment, <action> being one of the registered actions’ __regid__.
Actionpath executes a query whose results is lost because of redirecting instead of direct traversal.
- exception cubicweb.web.views.urlpublishing.PathDontMatch#
exception used by url evaluators to notify they can’t evaluate a path
- class cubicweb.web.views.urlpublishing.URLPublisherComponent(vreg, default_method='view')#
Associate url path to view identifier / rql queries, by applying a chain of urlpathevaluator components.
An evaluator is a URLPathEvaluator subclass with an .evaluate_path method taking the request object and the path to publish as argument. It will either return a publishing method identifier and an rql query on success or raise a PathDontMatch exception on failure. URL evaluators are called according to their priority attribute, with 0 as the greatest priority and greater values as lower priority. The first evaluator returning a result or raising something else than PathDontMatch will stop the handlers chain.
- process(req, path)#
Given a URL (essentially characterized by a path on the server, but additional information may be found in the request object), return a publishing method identifier (e.g. controller) and an optional result set.
req (cubicweb.web.request.CubicWebRequestBase) – the request object
path (str) – the path of the resource to publish. If empty, None or “/” “view” is used as the default path.
- Return type
tuple(str, cubicweb.rset.ResultSet or None)
the publishing method identifier and an optional result set
NotFound – if no handler is able to decode the given path
- class cubicweb.web.views.urlpublishing.URLPathEvaluator(urlpublisher)#
- class cubicweb.web.views.urlpublishing.RawPathEvaluator(urlpublisher)#
handle path of the form:
- class cubicweb.web.views.urlpublishing.EidPathEvaluator(urlpublisher)#
handle path with the form:
- class cubicweb.web.views.urlpublishing.RestPathEvaluator(urlpublisher)#
handle path with the form:
<etype>[[/<attribute name>]/<attribute value>]*
- class cubicweb.web.views.urlpublishing.URLRewriteEvaluator(urlpublisher)#
tries to find a rewrite rule to apply
URL rewrite rule definitions are stored in URLRewriter objects