1 |
1 |
2 |
2 |
3 The `Request` class (`cubicweb.web`) |
3 The `Request` class (`cubicweb.web`) |
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 A._cwuest instance is created when an HTTP._cwuest is sent to the web server. |
6 A request instance is created when an HTTP request is sent to the web server. |
7 It contains informations such as form parameters, user authenticated, etc. |
7 It contains informations such as form parameters, user authenticated, etc. |
8 |
8 |
9 **Globally, a._cwuest represents a user query, either through HTTP or not |
9 **Globally, a request represents a user query, either through HTTP or not |
10 (we also talk about RQL queries on the server side for example).** |
10 (we also talk about RQL queries on the server side for example).** |
11 |
11 |
12 An instance of `Request` has the following attributes: |
12 An instance of `Request` has the following attributes: |
13 |
13 |
14 * `user`, instance of `cubicweb.common.utils.User` corresponding to the authenticated |
14 * `user`, instance of `cubicweb.common.utils.User` corresponding to the authenticated |
34 returns a *session* cookie which will expire when the user closes the browser |
34 returns a *session* cookie which will expire when the user closes the browser |
35 window) |
35 window) |
36 * `remove_cookie(cookie, key)`, forces a value to expire |
36 * `remove_cookie(cookie, key)`, forces a value to expire |
37 |
37 |
38 :URL handling: |
38 :URL handling: |
39 * `url()`, returns the full URL of the HTTP._cwuest |
39 * `url()`, returns the full URL of the HTTP request |
40 * `base_url()`, returns the root URL of the web application |
40 * `base_url()`, returns the root URL of the web application |
41 * `relative_path()`, returns the relative path of the._cwuest |
41 * `relative_path()`, returns the relative path of the request |
42 |
42 |
43 :And more...: |
43 :And more...: |
44 * `set_content_type(content_type, filename=None)`, adds the header HTTP |
44 * `set_content_type(content_type, filename=None)`, adds the header HTTP |
45 'Content-Type' |
45 'Content-Type' |
46 * `get_header(header)`, returns the value associated to an arbitrary header |
46 * `get_header(header)`, returns the value associated to an arbitrary header |
47 of the HTTP._cwuest |
47 of the HTTP request |
48 * `set_header(header, value)`, adds an arbitrary header in the response |
48 * `set_header(header, value)`, adds an arbitrary header in the response |
49 * `cursor()` returns a RQL cursor on the session |
49 * `cursor()` returns a RQL cursor on the session |
50 * `execute(*args, **kwargs)`, shortcut to ``.cursor().execute()`` |
50 * `execute(*args, **kwargs)`, shortcut to ``.cursor().execute()`` |
51 * `property_value(key)`, properties management (`CWProperty`) |
51 * `property_value(key)`, properties management (`CWProperty`) |
52 * dictionary `data` to store data to share informations between components |
52 * dictionary `data` to store data to share informations between components |
53 *while a._cwuest is executed* |
53 *while a request is executed* |
54 |
54 |
55 Please note that this class is abstract and that a concrete implementation |
55 Please note that this class is abstract and that a concrete implementation |
56 will be provided by the *frontend* web used (in particular *twisted* as of |
56 will be provided by the *frontend* web used (in particular *twisted* as of |
57 today). For the views or others that are executed on the server side, |
57 today). For the views or others that are executed on the server side, |
58 most of the interface of `Request` is defined in the session associated |
58 most of the interface of `Request` is defined in the session associated |