OpenQuizz
Une application de gestion des contenus pédagogiques
|
Public Member Functions | |
def | __init__ (self, name, import_name, static_folder=None, static_url_path=None, template_folder=None, url_prefix=None, subdomain=None, url_defaults=None, root_path=None, cli_group=_sentinel) |
def | record (self, func) |
def | record_once (self, func) |
def | make_setup_state (self, app, options, first_registration=False) |
def | register (self, app, options, first_registration=False) |
def | route (self, rule, **options) |
def | add_url_rule (self, rule, endpoint=None, view_func=None, **options) |
def | endpoint (self, endpoint) |
def | app_template_filter (self, name=None) |
def | add_app_template_filter (self, f, name=None) |
def | app_template_test (self, name=None) |
def | add_app_template_test (self, f, name=None) |
def | app_template_global (self, name=None) |
def | add_app_template_global (self, f, name=None) |
def | before_request (self, f) |
def | before_app_request (self, f) |
def | before_app_first_request (self, f) |
def | after_request (self, f) |
def | after_app_request (self, f) |
def | teardown_request (self, f) |
def | teardown_app_request (self, f) |
def | context_processor (self, f) |
def | app_context_processor (self, f) |
def | app_errorhandler (self, code) |
def | url_value_preprocessor (self, f) |
def | url_defaults (self, f) |
def | app_url_value_preprocessor (self, f) |
def | app_url_defaults (self, f) |
def | errorhandler (self, code_or_exception) |
def | register_error_handler (self, code_or_exception, f) |
![]() | |
def | __init__ (self, import_name, template_folder=None, root_path=None) |
def | static_folder (self) |
def | static_folder (self, value) |
def | static_url_path (self) |
def | static_url_path (self, value) |
def | has_static_folder (self) |
def | jinja_loader (self) |
def | get_send_file_max_age (self, filename) |
def | send_static_file (self, filename) |
def | open_resource (self, resource, mode="rb") |
Data Fields | |
name | |
url_prefix | |
subdomain | |
static_folder | |
static_url_path | |
deferred_functions | |
url_values_defaults | |
cli_group | |
![]() | |
cli | |
Static Public Attributes | |
bool | warn_on_modifications = False |
json_encoder = None | |
json_decoder = None | |
import_name = None | |
template_folder = None | |
root_path = None | |
![]() | |
import_name | |
template_folder | |
root_path | |
Represents a blueprint, a collection of routes and other app-related functions that can be registered on a real application later. A blueprint is an object that allows defining application functions without requiring an application object ahead of time. It uses the same decorators as :class:`~flask.Flask`, but defers the need for an application by recording them for later registration. Decorating a function with a blueprint creates a deferred function that is called with :class:`~flask.blueprints.BlueprintSetupState` when the blueprint is registered on an application. See :ref:`blueprints` for more information. .. versionchanged:: 1.1.0 Blueprints have a ``cli`` group to register nested CLI commands. The ``cli_group`` parameter controls the name of the group under the ``flask`` command. .. versionadded:: 0.7 :param name: The name of the blueprint. Will be prepended to each endpoint name. :param import_name: The name of the blueprint package, usually ``__name__``. This helps locate the ``root_path`` for the blueprint. :param static_folder: A folder with static files that should be served by the blueprint's static route. The path is relative to the blueprint's root path. Blueprint static files are disabled by default. :param static_url_path: The url to serve static files from. Defaults to ``static_folder``. If the blueprint does not have a ``url_prefix``, the app's static route will take precedence, and the blueprint's static files won't be accessible. :param template_folder: A folder with templates that should be added to the app's template search path. The path is relative to the blueprint's root path. Blueprint templates are disabled by default. Blueprint templates have a lower precedence than those in the app's templates folder. :param url_prefix: A path to prepend to all of the blueprint's URLs, to make them distinct from the rest of the app's routes. :param subdomain: A subdomain that blueprint routes will match on by default. :param url_defaults: A dict of default values that blueprint routes will receive by default. :param root_path: By default, the blueprint will automatically this based on ``import_name``. In certain situations this automatic detection can fail, so the path can be specified manually instead.
def __init__ | ( | self, | |
name, | |||
import_name, | |||
static_folder = None , |
|||
static_url_path = None , |
|||
template_folder = None , |
|||
url_prefix = None , |
|||
subdomain = None , |
|||
url_defaults = None , |
|||
root_path = None , |
|||
cli_group = _sentinel |
|||
) |
def add_app_template_filter | ( | self, | |
f, | |||
name = None |
|||
) |
Register a custom template filter, available application wide. Like :meth:`Flask.add_template_filter` but for a blueprint. Works exactly like the :meth:`app_template_filter` decorator. :param name: the optional name of the filter, otherwise the function name will be used.
def add_app_template_global | ( | self, | |
f, | |||
name = None |
|||
) |
Register a custom template global, available application wide. Like :meth:`Flask.add_template_global` but for a blueprint. Works exactly like the :meth:`app_template_global` decorator. .. versionadded:: 0.10 :param name: the optional name of the global, otherwise the function name will be used.
def add_app_template_test | ( | self, | |
f, | |||
name = None |
|||
) |
Register a custom template test, available application wide. Like :meth:`Flask.add_template_test` but for a blueprint. Works exactly like the :meth:`app_template_test` decorator. .. versionadded:: 0.10 :param name: the optional name of the test, otherwise the function name will be used.
def add_url_rule | ( | self, | |
rule, | |||
endpoint = None , |
|||
view_func = None , |
|||
** | options | ||
) |
Like :meth:`Flask.add_url_rule` but for a blueprint. The endpoint for the :func:`url_for` function is prefixed with the name of the blueprint.
def after_app_request | ( | self, | |
f | |||
) |
Like :meth:`Flask.after_request` but for a blueprint. Such a function is executed after each request, even if outside of the blueprint.
def after_request | ( | self, | |
f | |||
) |
Like :meth:`Flask.after_request` but for a blueprint. This function is only executed after each request that is handled by a function of that blueprint.
def app_context_processor | ( | self, | |
f | |||
) |
Like :meth:`Flask.context_processor` but for a blueprint. Such a function is executed each request, even if outside of the blueprint.
def app_errorhandler | ( | self, | |
code | |||
) |
Like :meth:`Flask.errorhandler` but for a blueprint. This handler is used for all requests, even if outside of the blueprint.
def app_template_filter | ( | self, | |
name = None |
|||
) |
Register a custom template filter, available application wide. Like :meth:`Flask.template_filter` but for a blueprint. :param name: the optional name of the filter, otherwise the function name will be used.
def app_template_global | ( | self, | |
name = None |
|||
) |
Register a custom template global, available application wide. Like :meth:`Flask.template_global` but for a blueprint. .. versionadded:: 0.10 :param name: the optional name of the global, otherwise the function name will be used.
def app_template_test | ( | self, | |
name = None |
|||
) |
Register a custom template test, available application wide. Like :meth:`Flask.template_test` but for a blueprint. .. versionadded:: 0.10 :param name: the optional name of the test, otherwise the function name will be used.
def app_url_defaults | ( | self, | |
f | |||
) |
Same as :meth:`url_defaults` but application wide.
def app_url_value_preprocessor | ( | self, | |
f | |||
) |
Same as :meth:`url_value_preprocessor` but application wide.
def before_app_first_request | ( | self, | |
f | |||
) |
Like :meth:`Flask.before_first_request`. Such a function is executed before the first request to the application.
def before_app_request | ( | self, | |
f | |||
) |
Like :meth:`Flask.before_request`. Such a function is executed before each request, even if outside of a blueprint.
def before_request | ( | self, | |
f | |||
) |
Like :meth:`Flask.before_request` but for a blueprint. This function is only executed before each request that is handled by a function of that blueprint.
def context_processor | ( | self, | |
f | |||
) |
Like :meth:`Flask.context_processor` but for a blueprint. This function is only executed for requests handled by a blueprint.
def endpoint | ( | self, | |
endpoint | |||
) |
Like :meth:`Flask.endpoint` but for a blueprint. This does not prefix the endpoint with the blueprint name, this has to be done explicitly by the user of this method. If the endpoint is prefixed with a `.` it will be registered to the current blueprint, otherwise it's an application independent endpoint.
def errorhandler | ( | self, | |
code_or_exception | |||
) |
Registers an error handler that becomes active for this blueprint only. Please be aware that routing does not happen local to a blueprint so an error handler for 404 usually is not handled by a blueprint unless it is caused inside a view function. Another special case is the 500 internal server error which is always looked up from the application. Otherwise works as the :meth:`~flask.Flask.errorhandler` decorator of the :class:`~flask.Flask` object.
def make_setup_state | ( | self, | |
app, | |||
options, | |||
first_registration = False |
|||
) |
Creates an instance of :meth:`~flask.blueprints.BlueprintSetupState` object that is later passed to the register callback functions. Subclasses can override this to return a subclass of the setup state.
def record | ( | self, | |
func | |||
) |
Registers a function that is called when the blueprint is registered on the application. This function is called with the state as argument as returned by the :meth:`make_setup_state` method.
def record_once | ( | self, | |
func | |||
) |
Works like :meth:`record` but wraps the function in another function that will ensure the function is only called once. If the blueprint is registered a second time on the application, the function passed is not called.
def register | ( | self, | |
app, | |||
options, | |||
first_registration = False |
|||
) |
Called by :meth:`Flask.register_blueprint` to register all views and callbacks registered on the blueprint with the application. Creates a :class:`.BlueprintSetupState` and calls each :meth:`record` callback with it. :param app: The application this blueprint is being registered with. :param options: Keyword arguments forwarded from :meth:`~Flask.register_blueprint`. :param first_registration: Whether this is the first time this blueprint has been registered on the application.
def register_error_handler | ( | self, | |
code_or_exception, | |||
f | |||
) |
Non-decorator version of the :meth:`errorhandler` error attach function, akin to the :meth:`~flask.Flask.register_error_handler` application-wide function of the :class:`~flask.Flask` object but for error handlers limited to this blueprint. .. versionadded:: 0.11
def route | ( | self, | |
rule, | |||
** | options | ||
) |
Like :meth:`Flask.route` but for a blueprint. The endpoint for the :func:`url_for` function is prefixed with the name of the blueprint.
def teardown_app_request | ( | self, | |
f | |||
) |
Like :meth:`Flask.teardown_request` but for a blueprint. Such a function is executed when tearing down each request, even if outside of the blueprint.
def teardown_request | ( | self, | |
f | |||
) |
Like :meth:`Flask.teardown_request` but for a blueprint. This function is only executed when tearing down requests handled by a function of that blueprint. Teardown request functions are executed when the request context is popped, even when no actual request was performed.
def url_defaults | ( | self, | |
f | |||
) |
Callback function for URL defaults for this blueprint. It's called with the endpoint and values and should update the values passed in place.
def url_value_preprocessor | ( | self, | |
f | |||
) |
Registers a function as URL value preprocessor for this blueprint. It's called before the view functions are called and can modify the url values provided.
cli_group |
deferred_functions |
|
static |
|
static |
|
static |
name |
|
static |
static_folder |
static_url_path |
subdomain |
|
static |
url_prefix |
url_values_defaults |
|
static |