Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/flask/__pycache__/blueprints.cpython-37.pyc

302 lines
22 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
<00>/<2F>]<5D>S<00>@sRdZddlmZddlmZddlmZe<06>ZGdd<07>de<06>ZGdd <09>d e<05>Z d
S) z<>
flask.blueprints
~~~~~~~~~~~~~~~~
Blueprints are the recommended way to implement larger or more
pluggable applications in Flask 0.7 and later.
:copyright: 2010 Pallets
:license: BSD-3-Clause
<EFBFBD>)<01>update_wrapper<65>)<01>_endpoint_from_view_func)<01>_PackageBoundObjectc@s"eZdZdZdd<03>Zddd<06>ZdS)<08>BlueprintSetupStatez<65>Temporary holder object for registering a blueprint with the
application. An instance of this class is created by the
:meth:`~flask.Blueprint.make_setup_state` method and later passed
to all register callback functions.
cCs<>||_||_||_||_|j<02>d<01>}|dkr4|jj}||_|j<02>d<02>}|dkrV|jj}||_t|jj<08>|_ |j <09>
|j<02>dd<04><02>dS)N<> subdomain<69>
url_prefix<EFBFBD> url_defaults<74>) <0B>app<70> blueprint<6E>options<6E>first_registration<6F>getrr<00>dict<63>url_values_defaultsr <00>update)<07>selfr r r rrrr
r
<00>3/tmp/pip-install-c3kgu56x/Flask/flask/blueprints.py<70>__init__s  zBlueprintSetupState.__init__NcKs<>|jdk r2|r,d<02>|j<00>d<02>|<01>d<02>f<02>}n|j}|<04>d|j<05>|dkrPt|<03>}|j}d|krpt|f|<04> d<04><01>}|j
j |d|j j |f|fd|i|<04><02>dS)z<>A helper method to register a rule (and optionally a view function)
to the application. The endpoint is automatically prefixed with the
blueprint's name.
N<>/r<00>defaultsz%s.%s)r<00>join<69>rstrip<69>lstrip<69>
setdefaultrrr r<00>popr <00> add_url_ruler <00>name)r<00>rule<6C>endpoint<6E> view_funcr rr
r
rrAs 
z BlueprintSetupState.add_url_rule)NN)<06>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__rrr
r
r
rrs%rc@s@eZdZdZdZdZdZdZdZdZ dZ
ddddddde fdd<05>Z dd<07>Z dd <09>Zd@d
d <0B>ZdAd d <0A>Zdd<0F>ZdBdd<11>Zdd<13>ZdCdd<15>ZdDdd<17>ZdEdd<19>ZdFdd<1B>ZdGdd<1D>ZdHdd<1F>Zd d!<21>Zd"d#<23>Zd$d%<25>Zd&d'<27>Zd(d)<29>Zd*d+<2B>Zd,d-<2D>Z d.d/<2F>Z!d0d1<64>Z"d2d3<64>Z#d4d5<64>Z$d6d7<64>Z%d8d9<64>Z&d:d;<3B>Z'd<d=<3D>Z(d>d?<3F>Z)dS)I<> Blueprinta<74> 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.
FNc CsRtj|||| d<01>||_||_||_||_||_g|_|dkrBi}||_|
|_ dS)N)<01> root_path)
rrrrr<00> static_folder<65>static_url_path<74>deferred_functionsr<00> cli_group) rr<00> import_namer(r)<00>template_folderrrr r'r+r
r
rr<00>s zBlueprint.__init__cCs4|jr$|jr$ddlm}|td<03><01>|j<05>|<01>dS)z<>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.
r)<01>warnzgThe blueprint was already registered once but is getting modified now. These changes will not show up.N)<07>_got_registered_once<63>warn_on_modifications<6E>warningsr.<00>Warningr*<00>append)r<00>funcr.r
r
r<00>record<72>s   zBlueprint.recordcs<00>fdd<02>}|<00>t|<02><00><02>S)z<>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.
cs|jr<0E>|<00>dS)N)r)<01>state)r4r
r<00>wrapper<65>sz&Blueprint.record_once.<locals>.wrapper)r5r)rr4r7r
)r4r<00> record_once<63>s zBlueprint.record_oncecCst||||<03>S)z<>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.
)r)rr r rr
r
r<00>make_setup_state<74>szBlueprint.make_setup_statecCs<>d|_|<00>|||<03>}|jr2|j|jd|jdd<04>x|jD] }||<04>q:W|<02>d|j<08>}|j j
sddS|dkr<>|j j
<EFBFBD> |j j
<EFBFBD>n8|t kr<>|j |j _ |j <09>|j <09>n||j _ |j <09>|j <09>dS)a4Called 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.
Tz/<path:filename>Zstatic)r!r r+N)r/r9Zhas_static_folderrr)Zsend_static_filer*rr+<00>cli<6C>commandsr<00> _sentinelrZ add_command)rr r rr6<00>deferredZcli_resolved_groupr
r
r<00>register<65>s&   
zBlueprint.registerc s<00><00><01>fdd<02>}|S)z<>Like :meth:`Flask.route` but for a blueprint. The endpoint for the
:func:`url_for` function is prefixed with the name of the blueprint.
cs$<00><00>d|j<01>}<01>j<02>||f<03><00>|S)Nr )rr"r)<02>fr )r rrr
r<00> decoratorsz"Blueprint.route.<locals>.decoratorr
)rrr r@r
)r rrr<00>routeszBlueprint.routec sP<00>rd<01>kstd<02><01><01>r4t<01>d<03>r4d<01>jks4td<04><01>|<00><03><00><01><02>fdd<06><08>dS)z<>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.
<20>.z+Blueprint endpoints should not contain dotsr"z4Blueprint view function name should not contain dotscs|j<00><02><00>f<03><01>S)N)r)<01>s)r r rr!r
r<00><lambda>&<00>z(Blueprint.add_url_rule.<locals>.<lambda>N)<04>AssertionError<6F>hasattrr"r5)rrr r!r r
)r r rr!rrs  zBlueprint.add_url_rulecs<00><00>fdd<02>}|S)a\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.
cs<00><01>fdd<02>}<01><02>|<01><00>S)Ncs<00>|jj<01><dS)N)r Zview_functions)r6)r r?r
r<00>register_endpoint1sz@Blueprint.endpoint.<locals>.decorator.<locals>.register_endpoint)r8)r?rH)r r)r?rr@0s
z%Blueprint.endpoint.<locals>.decoratorr
)rr r@r
)r rrr (szBlueprint.endpointcs<00><00>fdd<02>}|S)z<>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.
cs<00>j|<00>d<01>|S)N)r)<01>add_app_template_filter)r?)rrr
rr@Asz0Blueprint.app_template_filter.<locals>.decoratorr
)rrr@r
)rrr<00>app_template_filter9szBlueprint.app_template_filtercs<00><00>fdd<02>}|<00>|<03>dS)aIRegister 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.
cs<00>|jjj<02>p<12>j<dS)N)r <00> jinja_env<6E>filtersr")r6)r?rr
r<00>register_templatePsz<Blueprint.add_app_template_filter.<locals>.register_templateN)r8)rr?rrMr
)r?rrrIGs z!Blueprint.add_app_template_filtercs<00><00>fdd<02>}|S)aRegister 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.
cs<00>j|<00>d<01>|S)N)r)<01>add_app_template_test)r?)rrr
rr@_sz.Blueprint.app_template_test.<locals>.decoratorr
)rrr@r
)rrr<00>app_template_testUs
zBlueprint.app_template_testcs<00><00>fdd<02>}|<00>|<03>dS)aaRegister 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.
cs<00>|jjj<02>p<12>j<dS)N)r rK<00>testsr")r6)r?rr
rrMpsz:Blueprint.add_app_template_test.<locals>.register_templateN)r8)rr?rrMr
)r?rrrNes zBlueprint.add_app_template_testcs<00><00>fdd<02>}|S)aRegister 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.
cs<00>j|<00>d<01>|S)N)r)<01>add_app_template_global)r?)rrr
rr@sz0Blueprint.app_template_global.<locals>.decoratorr
)rrr@r
)rrr<00>app_template_globalus
zBlueprint.app_template_globalcs<00><00>fdd<02>}|<00>|<03>dS)aiRegister 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.
cs<00>|jjj<02>p<12>j<dS)N)r rK<00>globalsr")r6)r?rr
rrM<00>sz<Blueprint.add_app_template_global.<locals>.register_templateN)r8)rr?rrMr
)r?rrrQ<00>s z!Blueprint.add_app_template_globalcs<00><01><00><00>fdd<02><08><00>S)z<>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.
cs|jj<01><02>jg<00><02><04><00>S)N)r <00>before_request_funcsrrr3)rC)r?rr
rrD<00>rEz*Blueprint.before_request.<locals>.<lambda>)r8)rr?r
)r?rr<00>before_request<73>szBlueprint.before_requestcs|<00><00>fdd<02><08><00>S)z<>Like :meth:`Flask.before_request`. Such a function is executed
before each request, even if outside of a blueprint.
cs|jj<01>dg<00><02><03><00>S)N)r rTrr3)rC)r?r
rrD<00>rEz.Blueprint.before_app_request.<locals>.<lambda>)r8)rr?r
)r?r<00>before_app_request<73>szBlueprint.before_app_requestcs|<00><00>fdd<02><08><00>S)z<>Like :meth:`Flask.before_first_request`. Such a function is
executed before the first request to the application.
cs|jj<01><02><00>S)N)r Zbefore_first_request_funcsr3)rC)r?r
rrD<00>rEz4Blueprint.before_app_first_request.<locals>.<lambda>)r8)rr?r
)r?r<00>before_app_first_request<73>sz"Blueprint.before_app_first_requestcs<00><01><00><00>fdd<02><08><00>S)z<>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.
cs|jj<01><02>jg<00><02><04><00>S)N)r <00>after_request_funcsrrr3)rC)r?rr
rrD<00>rEz)Blueprint.after_request.<locals>.<lambda>)r8)rr?r
)r?rr<00> after_request<73>szBlueprint.after_requestcs|<00><00>fdd<02><08><00>S)z<>Like :meth:`Flask.after_request` but for a blueprint. Such a function
is executed after each request, even if outside of the blueprint.
cs|jj<01>dg<00><02><03><00>S)N)r rXrr3)rC)r?r
rrD<00>rEz-Blueprint.after_app_request.<locals>.<lambda>)r8)rr?r
)r?r<00>after_app_request<73>szBlueprint.after_app_requestcs<00><01><00><00>fdd<02><08><00>S)a=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.
cs|jj<01><02>jg<00><02><04><00>S)N)r <00>teardown_request_funcsrrr3)rC)r?rr
rrD<00>rEz,Blueprint.teardown_request.<locals>.<lambda>)r8)rr?r
)r?rr<00>teardown_request<73>szBlueprint.teardown_requestcs|<00><00>fdd<02><08><00>S)z<>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.
cs|jj<01>dg<00><02><03><00>S)N)r r[rr3)rC)r?r
rrD<00>rEz0Blueprint.teardown_app_request.<locals>.<lambda>)r8)rr?r
)r?r<00>teardown_app_request<73>szBlueprint.teardown_app_requestcs<00><01><00><00>fdd<02><08><00>S)z<>Like :meth:`Flask.context_processor` but for a blueprint. This
function is only executed for requests handled by a blueprint.
cs|jj<01><02>jg<00><02><04><00>S)N)r <00>template_context_processorsrrr3)rC)r?rr
rrD<00>s
z-Blueprint.context_processor.<locals>.<lambda>)r8)rr?r
)r?rr<00>context_processor<6F>szBlueprint.context_processorcs|<00><00>fdd<02><08><00>S)z<>Like :meth:`Flask.context_processor` but for a blueprint. Such a
function is executed each request, even if outside of the blueprint.
cs|jj<01>dg<00><02><03><00>S)N)r r^rr3)rC)r?r
rrD<00>rEz1Blueprint.app_context_processor.<locals>.<lambda>)r8)rr?r
)r?r<00>app_context_processor<6F>szBlueprint.app_context_processorcs<00><00>fdd<02>}|S)z<>Like :meth:`Flask.errorhandler` but for a blueprint. This
handler is used for all requests, even if outside of the blueprint.
cs<00><02><00><01>fdd<02><08><00>S)Ncs|j<00><01><00><01><01>S)N)r <00> errorhandler)rC)<02>coder?r
rrD<00>rEz?Blueprint.app_errorhandler.<locals>.decorator.<locals>.<lambda>)r8)r?)rbr)r?rr@<00>sz-Blueprint.app_errorhandler.<locals>.decoratorr
)rrbr@r
)rbrr<00>app_errorhandler<65>szBlueprint.app_errorhandlercs<00><01><00><00>fdd<02><08><00>S)z<>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.
cs|jj<01><02>jg<00><02><04><00>S)N)r <00>url_value_preprocessorsrrr3)rC)r?rr
rrD<00>rEz2Blueprint.url_value_preprocessor.<locals>.<lambda>)r8)rr?r
)r?rr<00>url_value_preprocessor<6F>sz Blueprint.url_value_preprocessorcs<00><01><00><00>fdd<02><08><00>S)z<>Callback function for URL defaults for this blueprint. It's called
with the endpoint and values and should update the values passed
in place.
cs|jj<01><02>jg<00><02><04><00>S)N)r <00>url_default_functionsrrr3)rC)r?rr
rrDrEz(Blueprint.url_defaults.<locals>.<lambda>)r8)rr?r
)r?rrr szBlueprint.url_defaultscs|<00><00>fdd<02><08><00>S)zESame as :meth:`url_value_preprocessor` but application wide.
cs|jj<01>dg<00><02><03><00>S)N)r rdrr3)rC)r?r
rrDrEz6Blueprint.app_url_value_preprocessor.<locals>.<lambda>)r8)rr?r
)r?r<00>app_url_value_preprocessor sz$Blueprint.app_url_value_preprocessorcs|<00><00>fdd<02><08><00>S)z;Same as :meth:`url_defaults` but application wide.
cs|jj<01>dg<00><02><03><00>S)N)r rfrr3)rC)r?r
rrDrEz,Blueprint.app_url_defaults.<locals>.<lambda>)r8)rr?r
)r?r<00>app_url_defaultsszBlueprint.app_url_defaultscs<00><00>fdd<02>}|S)a 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.
cs<00><02><00><01><00>fdd<02><08><00>S)Ncs|j<00><01>j<02><00><01>S)N)r <00>_register_error_handlerr)rC)<03>code_or_exceptionr?rr
rrD)rEz;Blueprint.errorhandler.<locals>.decorator.<locals>.<lambda>)r8)r?)rjr)r?rr@'sz)Blueprint.errorhandler.<locals>.decoratorr
)rrjr@r
)rjrrras zBlueprint.errorhandlercs<00><02><00><00><01>fdd<02><08>dS)a1Non-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
cs|j<00><01>j<02><00><01>S)N)r rir)rC)rjr?rr
rrD8rEz2Blueprint.register_error_handler.<locals>.<lambda>N)r8)rrjr?r
)rjr?rr<00>register_error_handler/sz Blueprint.register_error_handler)F)F)NN)N)N)N)N)N)N)*r"r#r$r%r0r/Z json_encoderZ json_decoderr,r-r'r<rr5r8r9r>rArr rJrIrOrNrRrQrUrVrWrYrZr\r]r_r`rcrer rgrhrarkr
r
r
rr&ZsZ3 

'







 
  
   

r&N)
r%<00> functoolsrZhelpersrr<00>objectr<rr&r
r
r
r<00><module> s    E