6V=j=`ddlmZddlZddlZddlmZddlmZddl mZ ddl m Z dd l m Z dd l mZdd l mZejrdd lmZejd gdfZejde jejZejde jZejde jZejde jZejde jZ ejde j!Z"ejde j#Z$ejde j%Z&ejde j'Z(ejde j)Z*Gdd Z+GddeZ,dS)) annotationsN) defaultdict)update_wrapper)typing)_endpoint_from_view_func) _sentinel)Scaffold) setupmethod)AppBlueprintSetupStateT_after_request)boundT_before_requestT_error_handler T_teardownT_template_context_processorT_template_filterT_template_globalT_template_testT_url_defaultsT_url_value_preprocessorc(eZdZdZdd Z dddZd S)rzTemporary 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. blueprint Blueprintappr optionst.Anyfirst_registrationboolreturnNonec&||_||_||_||_|jd}| |jj}||_|jd}| |jj}||_|jd|j|_|jdd|_t|jj |_ |j |jdddS)N subdomain url_prefixname name_prefix url_defaults) rrrr getr%r&r'r(dicturl_values_defaultsr*update)selfrrrr r%r&s EC:\PYTHON\_runtimes\venv\Lib\site-packages\flask/sansio/blueprints.py__init__zBlueprintSetupState.__init__)s# #5L$$[11  0I#\%%l33  2J%L$$VY^<< <++M2>>!!CDD   !1!1."!E!EFFFFFNrulestrendpoint str | None view_funcft.RouteCallable | Nonec |jL|rCd|jd|df}n|j}|d|j|t |}|j}d|vr t|fi| d}|j j ||j d|j d|d|fd|i|dS)zA 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%defaults.)r&joinrstriplstrip setdefaultr%r r*r-popr add_url_ruler(r')r0r4r6r8rr<s r1rCz BlueprintSetupState.add_url_ruleWs ? & 'xx!7!7!N>N OPP;777  / ::H$  H@@ J(?(?@@H  8 8$) 8 8h 8 8 ? ? D D           r3) rrrr rrr r!r"r#)NN) r4r5r6r7r8r9rrr"r#)__name__ __module__ __qualname____doc__r2rCr+r3r1rr"sX ,G,G,G,Gb $-1        r3ceZdZdZdZdddddddefdLfd ZdMdZedNdZ edNdZ dOdPd"Z edQd%Z dRd&Z dSd'Ze dTdUd.Ze dVdWd0Ze dVdXd3Ze dVdYd5Ze dVdZd7Ze dVd[d9Ze dVd\d;Zed]d=Zed^d?Zed_dAZed`dCZedadGZedbdIZedcdKZxZS)dra 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 :doc:`/blueprints` for more information. :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 set this based on ``import_name``. In certain situations this automatic detection can fail, so the path can be specified manually instead. .. 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 FNr'r5 import_name static_folderstr | os.PathLike[str] | Nonestatic_url_pathr7template_folderr&r%r*dict[str, t.Any] | None root_path cli_groupc t||||| |stdd|vrtd||_||_||_g|_|i}||_| |_g|_ dS)N)rIrJrLrMrOz'name' may not be empty.r=z+'name' may not contain a dot '.' character.) superr2 ValueErrorr'r&r%deferred_functionsr.rP _blueprints) r0r'rIrJrLrMr&r%r*rOrP __class__s r1r2zBlueprint.__init__s #'++     9788 8 $;;JKK K $"?A  L#/ "EGr3f_namer"r#cJ|jrtd|d|jddS)NzThe setup method 'z,' can no longer be called on the blueprint 'z'. It has already been registered at least once, any changes will not be applied consistently. Make sure all imports, decorators, functions, etc. needed to set up the blueprint are done before registering it.)_got_registered_onceAssertionErrorr')r0rWs r1_check_setup_finishedzBlueprint._check_setup_finishedsT  $  AVAAYAAA   r3funcDeferredSetupFunctionc:|j|dS)zRegisters 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. N)rTappend)r0r\s r1recordzBlueprint.records! &&t,,,,,r3cZdfd }|t|dS)zWorks 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. staterr"r#c0|jr |dSdSN)r )rbr\s r1wrapperz&Blueprint.record_once..wrappers)' U   r3Nrbrr"r#)r`r)r0r\res ` r1 record_oncezBlueprint.record_oncesE       N7D1122222r3rr rdict[str, t.Any]r r!rc&t||||S)zCreates 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)r0rrr s r1make_setup_statezBlueprint.make_setup_states#4g7IJJJr3rrc d||urtd|j||fdS)aRegister a :class:`~flask.Blueprint` on this blueprint. Keyword arguments passed to this method will override the defaults set on the blueprint. .. versionchanged:: 2.0.1 The ``name`` option can be used to change the (pre-dotted) name the blueprint is registered with. This allows the same blueprint to be registered multiple times with unique names for ``url_for``. .. versionadded:: 2.0 z%Cannot register a blueprint on itselfN)rSrUr_)r0rrs r1register_blueprintzBlueprint.register_blueprints@   DEE E G 455555r3c |dd}|dj}|d|d}||jvr:|j|urdnd}||krd|dnd}t d |d |d |d t fd |jD }||jv} |j|<d_|||} j r%| j dj d|s| r ||jD] } | | |dj} jjr| *|jjjjn`| t&ur,|j_|jjn+| j_|jjjD]\} }|}|d}|d}|| j}| j||dz| jz|d<n|||d<n| j | j|d<|| j}| j9|7| jddz|dz|d<n|||d<n| j | j|d<||d<| ||dS)aCalled 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`. .. versionchanged:: 2.3 Nested blueprints now correctly apply subdomains. .. versionchanged:: 2.1 Registering the same blueprint with the same name multiple times is an error. .. versionchanged:: 2.0.1 Nested blueprints are registered with their dotted name. This allows different blueprints with the same name to be nested at different locations. .. versionchanged:: 2.0.1 The ``name`` option can be used to change the (pre-dotted) name the blueprint is registered with. This allows the same blueprint to be registered multiple times with unique names for ``url_for``. r(r)r'r=thisz a differentz ''z The name 'z' is already registered for z blueprintz'. Use 'name=' to provide a unique name.c3 K|]}|uV dSrdr+).0bpr0s r1 z%Blueprint.register..<s''U'Urd 'U'U'U'U'U'Ur3Tz/static)r8r6rPNr&r%r;)r,r'r@ blueprintsrSanyvaluesrYrjhas_static_folderrCrLsend_static_file_merge_blueprint_funcsrTrPclicommandsr/r add_commandrUcopyr%r&r?register)r0rrr( self_namer'bp_desc existing_atfirst_bp_registrationfirst_name_registrationrbdeferredcli_resolved_groupr bp_options bp_url_prefix bp_subdomains` r1rzBlueprint.registers:kk-44 KK 22 ++ ++22377 3> ! ! #t 4 < >+66L#(2 *|/G*6*.extend|s] '}} 0 0 V!kdd$C ''//// 0 0r3r=cRi|]$\}}|d|D%S)ci|]\}}|| Sr+r+)rq exc_classr\s r1 z?Blueprint._merge_blueprint_funcs...sVVVy$9dVVVr3)r)rqcode code_valuess r1rz4Blueprint._merge_blueprint_funcs..sI)kVV+BSBSBUBUVVVr3)rrrrr"r#) error_handler_specrrr-view_functionsbefore_request_funcsafter_request_funcsteardown_request_funcsurl_default_functionsurl_value_preprocessorstemplate_context_processors)r0rr'rrvaluer6r\s ` r1rzz Blueprint._merge_blueprint_funcs{sv 0 0 0 0 0 017799 0 0JC+$$d??S??C-2[[]]E+0C "3 ' '"17799 0 0NHd+/C x ( (t(#*BCCCt')@AAA  '  &    t)3+DEEEt+S-HIIIt/1PQQQQQr3r4r6r8r9provide_automatic_options bool | Nonec rdvrtdr(tdrdjvrtd|fddS)aRegister a URL rule with the blueprint. See :meth:`.Flask.add_url_rule` for full documentation. The URL rule is prefixed with the blueprint's URL prefix. The endpoint name, used with :func:`url_for`, is prefixed with the blueprint's name. r=z/'endpoint' may not contain a dot '.' character.rDz5'view_func' name may not contain a dot '.' character.c(|jfdiS)Nr)rC)sr6rrr4r8s r1z(Blueprint.add_url_rule..s8nan+D   r3N)rShasattrrDr`)r0r4r6r8rrs `````r1rCzBlueprint.add_url_rules  PxNOO O  VJ77 VC9CU.decorator!  ( ( ( 6 6 6Hr3)rrr"rr+r0r'rs`` r1app_template_filterzBlueprint.app_template_filters/       r3rft.TemplateFilterCallablecBdfd }||dS)aIRegister a template filter, available in any template rendered by the application. Works like the :meth:`app_template_filter` decorator. Equivalent to :meth:`.Flask.add_template_filter`. :param name: the optional name of the filter, otherwise the function name will be used. rbrr"r#c>|jjjpj<dSrd)r jinja_envfiltersrDrbrr's r1register_templatez.register_template">?EI  '(: ; ; ;r3Nrfrgr0rr'rs `` r1rz!Blueprint.add_app_template_filtersK @ @ @ @ @ @ @ *+++++r3.t.Callable[[T_template_test], T_template_test]cdfd }|S)a!Register a template test, available in any template rendered by the application. Equivalent to :meth:`.Flask.template_test`. .. versionadded:: 0.10 :param name: the optional name of the test, otherwise the function name will be used. rrr"c6||Sr)add_app_template_testrs r1rz.Blueprint.app_template_test..decorators!  & &qt & 4 4 4Hr3)rrr"rr+rs`` r1app_template_testzBlueprint.app_template_test/       r3ft.TemplateTestCallablecBdfd }||dS)aaRegister a template test, available in any template rendered by the application. Works like the :meth:`app_template_test` decorator. Equivalent to :meth:`.Flask.add_template_test`. .. versionadded:: 0.10 :param name: the optional name of the test, otherwise the function name will be used. rbrr"r#c>|jjjpj<dSrd)rrtestsrDrs r1rz:Blueprint.add_app_template_test..register_templates"<=EI  %d&8aj 9 9 9r3Nrfrrs `` r1rzBlueprint.add_app_template_testsD > > > > > > > *+++++r32t.Callable[[T_template_global], T_template_global]cdfd }|S)a'Register a template global, available in any template rendered by the application. Equivalent to :meth:`.Flask.template_global`. .. versionadded:: 0.10 :param name: the optional name of the global, otherwise the function name will be used. rrr"c6||Sr)add_app_template_globalrs r1rz0Blueprint.app_template_global..decoratorrr3)rrr"rr+rs`` r1app_template_globalzBlueprint.app_template_globalrr3ft.TemplateGlobalCallablecBdfd }||dS)aiRegister a template global, available in any template rendered by the application. Works like the :meth:`app_template_global` decorator. Equivalent to :meth:`.Flask.add_template_global`. .. versionadded:: 0.10 :param name: the optional name of the global, otherwise the function name will be used. rbrr"r#c>|jjjpj<dSrd)rrglobalsrDrs r1rz.register_template$rr3Nrfrrs `` r1rz!Blueprint.add_app_template_globalsK @ @ @ @ @ @ @ *+++++r3rc8|fdS)zLike :meth:`before_request`, but before every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.before_request`. cj|jjdgSrd)rrrAr_rrs r1rz.Blueprint.before_app_request../s*ae0;;D"EELLQOOr3rr0rs `r1before_app_requestzBlueprint.before_app_request)s0  O O O O   r3rc8|fdS)zLike :meth:`after_request`, but after every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.after_request`. cj|jjdgSrd)rrrAr_rs r1rz-Blueprint.after_app_request..9s*ae/::4DDKKANNr3rrs `r1after_app_requestzBlueprint.after_app_request3s0  N N N N   r3rc8|fdS)zLike :meth:`teardown_request`, but after every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.teardown_request`. cj|jjdgSrd)rrrAr_rs r1rz0Blueprint.teardown_app_request..Cs*ae2==dBGGNNqQQr3rrs `r1teardown_app_requestzBlueprint.teardown_app_request=s0  Q Q Q Q   r3rc8|fdS)zLike :meth:`context_processor`, but for templates rendered by every view, not only by the blueprint. Equivalent to :meth:`.Flask.context_processor`. cj|jjdgSrd)rrrAr_rs r1rz1Blueprint.app_context_processor..Os+ae7BB4LLSSTUVVr3rrs `r1app_context_processorzBlueprint.app_context_processorGs0  V V V V   r3rtype[Exception] | int.t.Callable[[T_error_handler], T_error_handler]cdfd }|S)zLike :meth:`errorhandler`, but for every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.errorhandler`. rrr"cBdfd }|S)Nrbrr"r#cN|jdSrd)r errorhandler)rbrrs r1from_blueprintzEBlueprint.app_errorhandler..decorator..from_blueprint\s), &&t,,Q/////r3rfr)rrrr0s` r1rz-Blueprint.app_errorhandler..decorator[sB 0 0 0 0 0 0 0   ^ , , ,Hr3)rrr"rr+)r0rrs`` r1app_errorhandlerzBlueprint.app_errorhandlerSs/       r3rc8|fdS)zLike :meth:`url_value_preprocessor`, but for every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.url_value_preprocessor`. cj|jjdgSrd)rrrAr_rs r1rz6Blueprint.app_url_value_preprocessor..ls+ae3>>tRHHOOPQRRr3rrs `r1app_url_value_preprocessorz$Blueprint.app_url_value_preprocessords0  R R R R   r3rc8|fdS)zLike :meth:`url_defaults`, but for every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.url_defaults`. cj|jjdgSrd)rrrAr_rs r1rz,Blueprint.app_url_defaults..vs*ae1<rsh"""""" ######$$$$$$......!!!!!!? $9#:D#@A!)-R5LQU5STTT19/r7OPPP!)-R5LMMM QY|2+> ? ? ? (qy""*M   AI19RSSSAI19RSSS!)-R5LMMM+23HIII$19b&E R R R R R R R R jAAAAAAAAAAr3