15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """Associate url's path to view identifier / rql queries. |
18 """Associate url's path to view identifier / rql queries. |
19 |
19 |
20 It currently handles url path with the forms: |
20 CubicWeb finds all registered URLPathEvaluators, orders them according |
21 |
21 to their ``priority`` attribute and calls their ``evaluate_path()`` |
22 * <publishing_method> |
22 method. The first that returns something and doesn't raise a |
23 * minimal REST publishing: |
23 ``PathDontMatch`` exception wins. |
24 |
24 |
25 * <eid> |
25 Here is the default evaluator chain: |
26 * <etype>[/<attribute name>/<attribute value>]* |
26 |
27 * folder navigation |
27 1. :class:`cubicweb.web.views.urlpublishing.RawPathEvaluator` handles |
28 |
28 unique url segments that match exactly one of the registered |
29 You can actually control URL (more exactly path) resolution using an |
29 controller's *__regid__*. Urls such as */view?*, */edit?*, */json?* |
30 URL path evaluator. |
30 fall in that category; |
|
31 |
|
32 2. :class:`cubicweb.web.views.urlpublishing.EidPathEvaluator` handles |
|
33 unique url segments that are eids (e.g. */1234*); |
|
34 |
|
35 3. :class:`cubicweb.web.views.urlpublishing.URLRewriteEvaluator` |
|
36 selects all urlrewriter components, sorts them according to their |
|
37 priorty, call their ``rewrite()`` method, the first one that |
|
38 doesn't raise a ``KeyError`` wins. This is where the |
|
39 :mod:`cubicweb.web.views.urlrewrite` and |
|
40 :class:`cubicweb.web.views.urlrewrite.SimpleReqRewriter` comes into |
|
41 play; |
|
42 |
|
43 4. :class:`cubicweb.web.views.urlpublishing.RestPathEvaluator` handles |
|
44 urls based on entity types and attributes : <etype>((/<attribute |
|
45 name>])?/<attribute value>)? This is why ``cwuser/carlos`` works; |
|
46 |
|
47 5. :class:`cubicweb.web.views.urlpublishing.ActionPathEvaluator` |
|
48 handles any of the previous paths with an additional trailing |
|
49 "/<action>" segment, <action> being one of the registered actions' |
|
50 __regid__. |
|
51 |
31 |
52 |
32 .. note:: |
53 .. note:: |
33 |
54 |
34 Actionpath and Folderpath execute a query whose results is lost |
55 Actionpath executes a query whose results is lost |
35 because of redirecting instead of direct traversal. |
56 because of redirecting instead of direct traversal. |
36 """ |
57 """ |
37 __docformat__ = "restructuredtext en" |
58 __docformat__ = "restructuredtext en" |
38 |
59 |
39 from rql import TypeResolverException |
60 from rql import TypeResolverException |