|
OpenQuizz
Une application de gestion des contenus pédagogiques
|


Public Member Functions | |
| def | __init__ (self, rules=None, default_subdomain="", charset="utf-8", strict_slashes=True, merge_slashes=True, redirect_defaults=True, converters=None, sort_parameters=False, sort_key=None, encoding_errors="replace", host_matching=False) |
| def | is_endpoint_expecting (self, endpoint, *arguments) |
| def | iter_rules (self, endpoint=None) |
| def | add (self, rulefactory) |
| def | bind (self, server_name, script_name=None, subdomain=None, url_scheme="http", default_method="GET", path_info=None, query_args=None) |
| def | bind_to_environ (self, environ, server_name=None, subdomain=None) |
| def | update (self) |
| def | __repr__ (self) |
Data Fields | |
| default_subdomain | |
| charset | |
| encoding_errors | |
| strict_slashes | |
| merge_slashes | |
| redirect_defaults | |
| host_matching | |
| converters | |
| sort_parameters | |
| sort_key | |
Static Public Attributes | |
| default_converters | |
| lock_class | |
The map class stores all the URL rules and some configuration
parameters. Some of the configuration values are only stored on the
`Map` instance since those affect all rules, others are just defaults
and can be overridden for each rule. Note that you have to specify all
arguments besides the `rules` as keyword arguments!
:param rules: sequence of url rules for this map.
:param default_subdomain: The default subdomain for rules without a
subdomain defined.
:param charset: charset of the url. defaults to ``"utf-8"``
:param strict_slashes: If a rule ends with a slash but the matched
URL does not, redirect to the URL with a trailing slash.
:param merge_slashes: Merge consecutive slashes when matching or
building URLs. Matches will redirect to the normalized URL.
Slashes in variable parts are not merged.
:param redirect_defaults: This will redirect to the default rule if it
wasn't visited that way. This helps creating
unique URLs.
:param converters: A dict of converters that adds additional converters
to the list of converters. If you redefine one
converter this will override the original one.
:param sort_parameters: If set to `True` the url parameters are sorted.
See `url_encode` for more details.
:param sort_key: The sort key function for `url_encode`.
:param encoding_errors: the error method to use for decoding
:param host_matching: if set to `True` it enables the host matching
feature and disables the subdomain one. If
enabled the `host` parameter to rules is used
instead of the `subdomain` one.
.. versionchanged:: 1.0
If ``url_scheme`` is ``ws`` or ``wss``, only WebSocket rules
will match.
.. versionchanged:: 1.0
Added ``merge_slashes``.
.. versionchanged:: 0.7
Added ``encoding_errors`` and ``host_matching``.
.. versionchanged:: 0.5
Added ``sort_parameters`` and ``sort_key``.
| def __init__ | ( | self, | |
rules = None, |
|||
default_subdomain = "", |
|||
charset = "utf-8", |
|||
strict_slashes = True, |
|||
merge_slashes = True, |
|||
redirect_defaults = True, |
|||
converters = None, |
|||
sort_parameters = False, |
|||
sort_key = None, |
|||
encoding_errors = "replace", |
|||
host_matching = False |
|||
| ) |
| def __repr__ | ( | self | ) |
| def add | ( | self, | |
| rulefactory | |||
| ) |
Add a new rule or factory to the map and bind it. Requires that the rule is not bound to another map. :param rulefactory: a :class:`Rule` or :class:`RuleFactory`
| def bind | ( | self, | |
| server_name, | |||
script_name = None, |
|||
subdomain = None, |
|||
url_scheme = "http", |
|||
default_method = "GET", |
|||
path_info = None, |
|||
query_args = None |
|||
| ) |
Return a new :class:`MapAdapter` with the details specified to the
call. Note that `script_name` will default to ``'/'`` if not further
specified or `None`. The `server_name` at least is a requirement
because the HTTP RFC requires absolute URLs for redirects and so all
redirect exceptions raised by Werkzeug will contain the full canonical
URL.
If no path_info is passed to :meth:`match` it will use the default path
info passed to bind. While this doesn't really make sense for
manual bind calls, it's useful if you bind a map to a WSGI
environment which already contains the path info.
`subdomain` will default to the `default_subdomain` for this map if
no defined. If there is no `default_subdomain` you cannot use the
subdomain feature.
.. versionchanged:: 1.0
If ``url_scheme`` is ``ws`` or ``wss``, only WebSocket rules
will match.
.. versionchanged:: 0.15
``path_info`` defaults to ``'/'`` if ``None``.
.. versionchanged:: 0.8
``query_args`` can be a string.
.. versionchanged:: 0.7
Added ``query_args``.
| def bind_to_environ | ( | self, | |
| environ, | |||
server_name = None, |
|||
subdomain = None |
|||
| ) |
Like :meth:`bind` but you can pass it an WSGI environment and it
will fetch the information from that dictionary. Note that because of
limitations in the protocol there is no way to get the current
subdomain and real `server_name` from the environment. If you don't
provide it, Werkzeug will use `SERVER_NAME` and `SERVER_PORT` (or
`HTTP_HOST` if provided) as used `server_name` with disabled subdomain
feature.
If `subdomain` is `None` but an environment and a server name is
provided it will calculate the current subdomain automatically.
Example: `server_name` is ``'example.com'`` and the `SERVER_NAME`
in the wsgi `environ` is ``'staging.dev.example.com'`` the calculated
subdomain will be ``'staging.dev'``.
If the object passed as environ has an environ attribute, the value of
this attribute is used instead. This allows you to pass request
objects. Additionally `PATH_INFO` added as a default of the
:class:`MapAdapter` so that you don't have to pass the path info to
the match method.
.. versionchanged:: 1.0.0
If the passed server name specifies port 443, it will match
if the incoming scheme is ``https`` without a port.
.. versionchanged:: 1.0.0
A warning is shown when the passed server name does not
match the incoming WSGI server name.
.. versionchanged:: 0.8
This will no longer raise a ValueError when an unexpected server
name was passed.
.. versionchanged:: 0.5
previously this method accepted a bogus `calculate_subdomain`
parameter that did not have any effect. It was removed because
of that.
:param environ: a WSGI environment.
:param server_name: an optional server name hint (see above).
:param subdomain: optionally the current subdomain (see above).
| def is_endpoint_expecting | ( | self, | |
| endpoint, | |||
| * | arguments | ||
| ) |
Iterate over all rules and check if the endpoint expects
the arguments provided. This is for example useful if you have
some URLs that expect a language code and others that do not and
you want to wrap the builder a bit so that the current language
code is automatically added if not provided but endpoints expect
it.
:param endpoint: the endpoint to check.
:param arguments: this function accepts one or more arguments
as positional arguments. Each one of them is
checked.
| def iter_rules | ( | self, | |
endpoint = None |
|||
| ) |
Iterate over all rules or the rules of an endpoint.
:param endpoint: if provided only the rules for that endpoint
are returned.
:return: an iterator
| def update | ( | self | ) |
Called before matching and building to keep the compiled rules in the correct order after things changed.
| charset |
| converters |
|
static |
| default_subdomain |
| encoding_errors |
| host_matching |
|
static |
| merge_slashes |
| redirect_defaults |
| sort_key |
| sort_parameters |
| strict_slashes |