cubicweb.web.views.urlpublishing#

exception cubicweb.web.views.urlpublishing.PathDontMatch[source]#

exception used by url evaluators to notify they can’t evaluate a path

class cubicweb.web.views.urlpublishing.URLPublisherComponent(vreg, default_method='view')[source]#

Bases: cubicweb_web.view.Component

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)[source]#

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.

Parameters
  • 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)

Returns

the publishing method identifier and an optional result set

Raises

NotFound – if no handler is able to decode the given path

class cubicweb.web.views.urlpublishing.URLPathEvaluator(urlpublisher)[source]#

Bases: cubicweb_web.view.Component

class cubicweb.web.views.urlpublishing.RawPathEvaluator(urlpublisher)[source]#

Bases: cubicweb_web.views.urlpublishing.URLPathEvaluator

handle path of the form:

<publishing_method>?parameters...
class cubicweb.web.views.urlpublishing.EidPathEvaluator(urlpublisher)[source]#

Bases: cubicweb_web.views.urlpublishing.URLPathEvaluator

handle path with the form:

<eid>
class cubicweb.web.views.urlpublishing.RestPathEvaluator(urlpublisher)[source]#

Bases: cubicweb_web.views.urlpublishing.URLPathEvaluator

handle path with the form:

<etype>[[/<attribute name>]/<attribute value>]*
class cubicweb.web.views.urlpublishing.URLRewriteEvaluator(urlpublisher)[source]#

Bases: cubicweb_web.views.urlpublishing.URLPathEvaluator

tries to find a rewrite rule to apply

URL rewrite rule definitions are stored in URLRewriter objects

class cubicweb.web.views.urlpublishing.ActionPathEvaluator(urlpublisher)[source]#

Bases: cubicweb_web.views.urlpublishing.URLPathEvaluator

handle path with the form:

<any evaluator path>/<action>