OpenQuizz
Une application de gestion des contenus pédagogiques
|
Public Member Functions | |
def | __init__ (self, environ, populate_request=True, shallow=False) |
def | __repr__ (self) |
def | url_charset (self) |
def | from_values (cls, *args, **kwargs) |
def | application (cls, f) |
def | want_form_data_parsed (self) |
def | make_form_data_parser (self) |
def | close (self) |
def | __enter__ (self) |
def | __exit__ (self, exc_type, exc_value, tb) |
def | stream (self) |
def | args (self) |
def | data (self) |
def | get_data (self, cache=True, as_text=False, parse_form_data=False) |
def | form (self) |
def | values (self) |
def | files (self) |
def | cookies (self) |
def | headers (self) |
def | path (self) |
def | full_path (self) |
def | script_root (self) |
def | url (self) |
def | base_url (self) |
def | url_root (self) |
def | host_url (self) |
def | host (self) |
def | access_route (self) |
def | remote_addr (self) |
Data Fields | |
environ | |
shallow | |
Properties | |
is_secure | |
Very basic request object. This does not implement advanced stuff like entity tag parsing or cache controls. The request object is created with the WSGI environment as first argument and will add itself to the WSGI environment as ``'werkzeug.request'`` unless it's created with `populate_request` set to False. There are a couple of mixins available that add additional functionality to the request object, there is also a class called `Request` which subclasses `BaseRequest` and all the important mixins. It's a good idea to create a custom subclass of the :class:`BaseRequest` and add missing functionality either via mixins or direct implementation. Here an example for such subclasses:: from werkzeug.wrappers import BaseRequest, ETagRequestMixin class Request(BaseRequest, ETagRequestMixin): pass Request objects are **read only**. As of 0.5 modifications are not allowed in any place. Unlike the lower level parsing functions the request object will use immutable objects everywhere possible. Per default the request object will assume all the text data is `utf-8` encoded. Please refer to :doc:`the unicode chapter </unicode>` for more details about customizing the behavior. Per default the request object will be added to the WSGI environment as `werkzeug.request` to support the debugging system. If you don't want that, set `populate_request` to `False`. If `shallow` is `True` the environment is initialized as shallow object around the environ. Every operation that would modify the environ in any way (such as consuming form data) raises an exception unless the `shallow` attribute is explicitly set to `False`. This is useful for middlewares where you don't want to consume the form data by accident. A shallow request is not populated to the WSGI environment. .. versionchanged:: 0.5 read-only mode was enforced by using immutables classes for all data.
def __init__ | ( | self, | |
environ, | |||
populate_request = True , |
|||
shallow = False |
|||
) |
def __enter__ | ( | self | ) |
def __exit__ | ( | self, | |
exc_type, | |||
exc_value, | |||
tb | |||
) |
def __repr__ | ( | self | ) |
def access_route | ( | self | ) |
If a forwarded header exists this is a list of all ip addresses from the client ip to the last proxy server.
def application | ( | cls, | |
f | |||
) |
Decorate a function as responder that accepts the request as the last argument. This works like the :func:`responder` decorator but the function is passed the request object as the last argument and the request object will be closed automatically:: @Request.application def my_wsgi_app(request): return Response('Hello World!') As of Werkzeug 0.14 HTTP exceptions are automatically caught and converted to responses instead of failing. :param f: the WSGI callable to decorate :return: a new WSGI callable
def args | ( | self | ) |
The parsed URL parameters (the part in the URL after the question mark). By default an :class:`~werkzeug.datastructures.ImmutableMultiDict` is returned from this function. This can be changed by setting :attr:`parameter_storage_class` to a different type. This might be necessary if the order of the form data is important.
def base_url | ( | self | ) |
Like :attr:`url` but without the querystring See also: :attr:`trusted_hosts`.
def close | ( | self | ) |
Closes associated resources of this request object. This closes all file handles explicitly. You can also use the request object in a with statement which will automatically close it. .. versionadded:: 0.9
def cookies | ( | self | ) |
A :class:`dict` with the contents of all cookies transmitted with the request.
def data | ( | self | ) |
Contains the incoming request data as string in case it came with a mimetype Werkzeug does not handle.
def files | ( | self | ) |
:class:`~werkzeug.datastructures.MultiDict` object containing all uploaded files. Each key in :attr:`files` is the name from the ``<input type="file" name="">``. Each value in :attr:`files` is a Werkzeug :class:`~werkzeug.datastructures.FileStorage` object. It basically behaves like a standard file object you know from Python, with the difference that it also has a :meth:`~werkzeug.datastructures.FileStorage.save` function that can store the file on the filesystem. Note that :attr:`files` will only contain data if the request method was POST, PUT or PATCH and the ``<form>`` that posted to the request had ``enctype="multipart/form-data"``. It will be empty otherwise. See the :class:`~werkzeug.datastructures.MultiDict` / :class:`~werkzeug.datastructures.FileStorage` documentation for more details about the used data structure.
def form | ( | self | ) |
The form parameters. By default an :class:`~werkzeug.datastructures.ImmutableMultiDict` is returned from this function. This can be changed by setting :attr:`parameter_storage_class` to a different type. This might be necessary if the order of the form data is important. Please keep in mind that file uploads will not end up here, but instead in the :attr:`files` attribute. .. versionchanged:: 0.9 Previous to Werkzeug 0.9 this would only contain form data for POST and PUT requests.
def from_values | ( | cls, | |
* | args, | ||
** | kwargs | ||
) |
Create a new request object based on the values provided. If environ is given missing values are filled from there. This method is useful for small scripts when you need to simulate a request from an URL. Do not use this method for unittesting, there is a full featured client object (:class:`Client`) that allows to create multipart requests, support for cookies etc. This accepts the same options as the :class:`~werkzeug.test.EnvironBuilder`. .. versionchanged:: 0.5 This method now accepts the same arguments as :class:`~werkzeug.test.EnvironBuilder`. Because of this the `environ` parameter is now called `environ_overrides`. :return: request object
def full_path | ( | self | ) |
Requested path as unicode, including the query string.
def get_data | ( | self, | |
cache = True , |
|||
as_text = False , |
|||
parse_form_data = False |
|||
) |
This reads the buffered incoming data from the client into one bytestring. By default this is cached but that behavior can be changed by setting `cache` to `False`. Usually it's a bad idea to call this method without checking the content length first as a client could send dozens of megabytes or more to cause memory problems on the server. Note that if the form data was already parsed this method will not return anything as form data parsing does not cache the data like this method does. To implicitly invoke form data parsing function set `parse_form_data` to `True`. When this is done the return value of this method will be an empty string if the form parser handles the data. This generally is not necessary as if the whole data is cached (which is the default) the form parser will used the cached data to parse the form data. Please be generally aware of checking the content length first in any case before calling this method to avoid exhausting server memory. If `as_text` is set to `True` the return value will be a decoded unicode string. .. versionadded:: 0.9
def headers | ( | self | ) |
The headers from the WSGI environ as immutable :class:`~werkzeug.datastructures.EnvironHeaders`.
def host | ( | self | ) |
Just the host including the port if available. See also: :attr:`trusted_hosts`.
def host_url | ( | self | ) |
Just the host with scheme as IRI. See also: :attr:`trusted_hosts`.
def make_form_data_parser | ( | self | ) |
Creates the form data parser. Instantiates the :attr:`form_data_parser_class` with some parameters. .. versionadded:: 0.8
def path | ( | self | ) |
Requested path as unicode. This works a bit like the regular path info in the WSGI environment but will always include a leading slash, even if the URL root is accessed.
def remote_addr | ( | self | ) |
The remote address of the client.
def script_root | ( | self | ) |
The root path of the script without the trailing slash.
def stream | ( | self | ) |
If the incoming form data was not encoded with a known mimetype the data is stored unmodified in this stream for consumption. Most of the time it is a better idea to use :attr:`data` which will give you that data as a string. The stream only returns the data once. Unlike :attr:`input_stream` this stream is properly guarded that you can't accidentally read past the length of the input. Werkzeug will internally always refer to this stream to read data which makes it possible to wrap this object with a stream that does filtering. .. versionchanged:: 0.9 This stream is now always available but might be consumed by the form parser later on. Previously the stream was only set if no parsing happened.
def url | ( | self | ) |
The reconstructed current URL as IRI. See also: :attr:`trusted_hosts`.
def url_charset | ( | self | ) |
The charset that is assumed for URLs. Defaults to the value of :attr:`charset`. .. versionadded:: 0.6
def url_root | ( | self | ) |
The full URL root (with hostname), this is the application root as IRI. See also: :attr:`trusted_hosts`.
def values | ( | self | ) |
A :class:`werkzeug.datastructures.CombinedMultiDict` that combines :attr:`args` and :attr:`form`.
def want_form_data_parsed | ( | self | ) |
Returns True if the request method carries content. As of Werkzeug 0.9 this will be the case if a content type is transmitted. .. versionadded:: 0.8
|
static |
|
static |
|
static |
|
static |
|
static |
environ |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
shallow |
|
static |
|
static |