Commit 598abf65 authored by Élodie Thiéblin's avatar Élodie Thiéblin
Browse files

doc(urlpublish): add example with the empty_rset_raises_404 option

parent 296602ea52fc
Pipeline #35541 passed with stage
......@@ -122,6 +122,26 @@ Here is an example of ``SimpleReqRewriter`` usage with regular expressions:
When a url matches the regular expression, the view with the __regid__
`rss` which match the result set is displayed.
To deal with URL rewriting with an underlying RQL query, it is possible to
specify the behaviour in the case of an empty rset with the option
The following example shows a ``SimpleReqRewriter`` usage with the
`empty_rset_raises_404` option set to True.
In this case, the path mycwetypeurl/pouet will return a 404. Without this option,
it would return a 200.
.. sourcecode:: python
from cubicweb.web.views.urlrewrite import (
SimpleReqRewriter, rgx)
class MyRewriter(SimpleReqRewriter):
rules = [(rgx(r'/mycwetypeurl/([^/]+)'),
rql=r'Any T WHERE T is CWEType, T name "\1"',
Here is an example of ``SchemaBasedRewriter`` usage:
.. sourcecode:: python
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment