OpenQuizz
Une application de gestion des contenus pédagogiques
Blueprint Class Reference
Inheritance diagram for Blueprint:
Collaboration diagram for Blueprint:

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)
 
- Public Member Functions inherited from _PackageBoundObject
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
 
- Data Fields inherited from _PackageBoundObject
 cli
 

Static Public Attributes

bool warn_on_modifications = False
 
 json_encoder = None
 
 json_decoder = None
 
 import_name = None
 
 template_folder = None
 
 root_path = None
 
- Static Public Attributes inherited from _PackageBoundObject
 import_name
 
 template_folder
 
 root_path
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

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 
)

Member Function Documentation

◆ add_app_template_filter()

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.

◆ add_app_template_global()

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.

◆ add_app_template_test()

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.

◆ add_url_rule()

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.

◆ after_app_request()

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.

◆ after_request()

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.

◆ app_context_processor()

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.

◆ app_errorhandler()

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.

◆ app_template_filter()

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.

◆ app_template_global()

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.

◆ app_template_test()

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.

◆ app_url_defaults()

def app_url_defaults (   self,
  f 
)
Same as :meth:`url_defaults` but application wide.

◆ app_url_value_preprocessor()

def app_url_value_preprocessor (   self,
  f 
)
Same as :meth:`url_value_preprocessor` but application wide.

◆ before_app_first_request()

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.

◆ before_app_request()

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.

◆ before_request()

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.

◆ context_processor()

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.

◆ endpoint()

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.

◆ errorhandler()

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.

◆ make_setup_state()

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.

◆ record()

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.

◆ record_once()

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.

◆ register()

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.

◆ register_error_handler()

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

◆ route()

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.

◆ teardown_app_request()

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.

◆ teardown_request()

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.

◆ url_defaults()

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.

◆ url_value_preprocessor()

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.

Field Documentation

◆ cli_group

cli_group

◆ deferred_functions

deferred_functions

◆ import_name

import_name = None
static

◆ json_decoder

json_decoder = None
static

◆ json_encoder

json_encoder = None
static

◆ name

name

◆ root_path

root_path = None
static

◆ static_folder

static_folder

◆ static_url_path

static_url_path

◆ subdomain

subdomain

◆ template_folder

template_folder = None
static

◆ url_prefix

url_prefix

◆ url_values_defaults

url_values_defaults

◆ warn_on_modifications

bool warn_on_modifications = False
static

The documentation for this class was generated from the following file: