zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
U
ß=®d _ã@sVddlmZddlZddlZddlmZddlmZddl    mZ
ddl m Z ddl m Z dd    l mZdd
l mZejr‚dd lmZejd gejfZejd e
jdZejde
jdZejde
jdZejde
jdZejde
jdZejde
j dZ!ejde
j"dZ#ejde
j$dZ%ejde
j&dZ'ejde
j(dZ)Gdd „d ƒZ*Gdd„deƒZ+dS)é)Ú annotationsN)Ú defaultdict)Úupdate_wrapperé)Útyping)Ú_endpoint_from_view_func)Ú    _sentinel)ÚScaffold)Ú setupmethod)ÚFlaskÚBlueprintSetupStateÚT_after_request)ÚboundÚT_before_requestÚT_error_handlerÚ
T_teardownÚT_template_context_processorÚT_template_filterÚT_template_globalÚT_template_testÚT_url_defaultsÚT_url_value_preprocessorc@s>eZdZdZddddddœdd    „Zdd d d dddœdd„Zd
S)r zí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.
    Ú    Blueprintr út.AnyÚboolÚNone)Ú    blueprintÚappÚoptionsÚfirst_registrationÚreturncCs¦||_||_||_||_|j d¡}|dkr4|jj}||_|j d¡}|dkrV|jj}||_|j d|j¡|_|j dd¡|_t    |jj
ƒ|_ |j   |j dd¡¡dS)NÚ    subdomainÚ
url_prefixÚnameÚ name_prefixÚÚ url_defaults©) rrrrÚgetr!r"r#r$ÚdictÚurl_values_defaultsr&Úupdate)Úselfrrrrr!r"r'r'úGd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\flask/blueprints.pyÚ__init__)s   zBlueprintSetupState.__init__NÚstrú
str | Nonezt.Callable | None)ÚruleÚendpointÚ    view_funcrr cKsª|jdk    r2|r,d |j d¡| d¡f¡}n|j}| d|j¡|dkrPt|ƒ}|j}d|krpt|f|     d¡Ž}|j
j ||j ›d|j ›d|› d¡|fd|i|—Ž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!ÚdefaultsÚ.)r"ÚjoinÚrstripÚlstripÚ
setdefaultr!rr&r)ÚpoprÚ add_url_ruler$r#)r,r1r2r3rr5r'r'r-r<Ws&
ýüûz BlueprintSetupState.add_url_rule)NN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r.r<r'r'r'r-r "s
1üc søeZdZdZdZdddddddefdddddddddddœ
‡fd    d
„ Zdd d œd d„Zedd dœdd„ƒZ    edd dœdd„ƒZ
dTdddddœdd„Z eddd dœdd„ƒZ ddd d œd!d"„Z edUddd#d$dd d%œd&d'„ƒZedVdd(d)œd*d+„ƒZedWd,dd d-œd.d/„ƒZedXdd0d)œd1d2„ƒZedYd3dd d-œd4d5„ƒZedZdd6d)œd7d8„ƒZed[d9dd d-œd:d;„ƒZed<d<d=œd>d?„ƒZed@d@d=œdAdB„ƒZedCdCd=œdDdE„ƒZedFdFd=œdGdH„ƒZedIdJdKœdLdM„ƒZedNdNd=œdOdP„ƒZedQdQd=œdRdS„ƒZ‡ZS)\raã    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/zstr | os.PathLike | Noner0z dict | None)
r#Ú import_nameÚ static_folderÚstatic_url_pathÚtemplate_folderr"r!r&Ú    root_pathÚ    cli_groupc sltƒj|||||    d|s"tdƒ‚d|kr2tdƒ‚||_||_||_g|_|dkrVi}||_|
|_g|_    dS)N)rArBrCrDrEz'name' may not be empty.r6z+'name' may not contain a dot '.' character.)
Úsuperr.Ú
ValueErrorr#r"r!Údeferred_functionsr*rFÚ _blueprints) r,r#rArBrCrDr"r!r&rErF©Ú    __class__r'r-r.®s( ûzBlueprint.__init__r)Úf_namer cCs"|jrtd|›d|j›dƒ‚dS)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_onceÚAssertionErrorr#)r,rMr'r'r-Ú_check_setup_finishedÕsÿzBlueprint._check_setup_finishedz
t.Callable)Úfuncr cCs|j |¡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.
        N)rIÚappend)r,rQr'r'r-ÚrecordßszBlueprint.recordcs(dddœ‡fdd„ }| t|ˆƒ¡dS)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.
        r r©Ústater cs|jrˆ|ƒdS©N)r©rU©rQr'r-Úwrapperðsz&Blueprint.record_once.<locals>.wrapperN)rSr)r,rQrYr'rXr-Ú record_onceèszBlueprint.record_oncer r)rr )rrrr cCst||||ƒ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 )r,rrrr'r'r-Úmake_setup_stateöszBlueprint.make_setup_stater)rrr cKs$||krtdƒ‚|j ||f¡dS)aßRegister 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)rHrJrR)r,rrr'r'r-Úregister_blueprintÿszBlueprint.register_blueprint)rrr csf| dd¡}| dˆj¡}|›d|› d¡‰ˆ|jkr‚|jˆˆkrJdnd}|ˆkrbdˆ›dnd}td    |›d
|›d |›d ƒ‚t‡fd d„|j ¡Dƒƒ }ˆ|jk}ˆ|jˆ<dˆ_ˆ |||¡}    ˆj    rè|    j
ˆj ›dˆj dd|sò|rƇfdd„}
ˆj  ¡D]H\} } | dkrˆn ˆ›d| ›} ttdd„|  ¡Dƒƒ} | |j | <qˆj ¡D]\} }||j| <q\|
ˆj|jƒ|
ˆj|jƒ|
ˆj|jƒ|
ˆj|jƒ|
ˆj|jƒ|
ˆj|jƒˆjD]}||    ƒqÌ| dˆj¡}ˆjjrJ|dkr|jj ˆjj¡n8|tkr4ˆˆj_|j ˆj¡n|ˆj_|j ˆj¡ˆjD]\}}|  ¡}| d¡}| d¡}|dkr†|j!}|    j!dk    r°|dk    r°|d|    j!|d<n*|dk    rÄ||d<n|    j!dk    rÚ|    j!|d<|dkrê|j"}|    j"dk    r |dk    r |    j" #d¡d| d¡|d<n*|dk    r4||d<n|    j"dk    rJ|    j"|d<ˆ|d<| $||¡qPdS)a‘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`.
 
        .. 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#r6Úthisz a differentz 'ú'z
The name 'z' is already registered for z
 blueprintz'. Use 'name=' to provide a unique name.c3s|]}|ˆkVqdSrVr')Ú.0Zbp)r,r'r-Ú    <genexpr><sz%Blueprint.register.<locals>.<genexpr>Tz/<path:filename>Zstatic)r3r2cs>| ¡D]0\}}|dkrˆn ˆ›d|›}|| |¡qdS)Nr6)ÚitemsÚextend)Zbp_dictZ parent_dictÚkeyÚvalues©r#r'r-rbMsz"Blueprint.register.<locals>.extendNcSs$i|]\}}|dd„| ¡Dƒ“qS)cSsi|]\}}||“qSr'r')r_Ú    exc_classrQr'r'r-Ú
<dictcomp>Wsz1Blueprint.register.<locals>.<dictcomp>.<dictcomp>)ra)r_ÚcodeZ code_valuesr'r'r-rgVs
ýÿz&Blueprint.register.<locals>.<dictcomp>rFr"r!r4)%r(r#r9Z
blueprintsrHÚanyrdrNr[Zhas_static_folderr<rCZsend_static_fileZerror_handler_specrarr)Zview_functionsÚbefore_request_funcsÚafter_request_funcsÚteardown_request_funcsÚurl_default_functionsÚurl_value_preprocessorsÚtemplate_context_processorsrIrFÚcliÚcommandsr+rZ add_commandrJÚcopyr!r"r8Úregister)r,rrr$Z    self_nameZbp_descZ existing_atZfirst_bp_registrationZfirst_name_registrationrUrbrcÚvaluer2rQÚdeferredZcli_resolved_grouprZ
bp_optionsZ bp_url_prefixZ bp_subdomainr'©r#r,r-rss˜ 
ÿ
 
 
ý
 üþ    þ
 
 
 
 
 
 
 
 
 
 
ÿ
 
 
zBlueprint.registerzft.RouteCallable | Nonez bool | None)r1r2r3Úprovide_automatic_optionsrr c sRˆrdˆkrtdƒ‚ˆr4tˆdƒr4dˆjkr4tdƒ‚| ‡‡‡‡‡fdd„¡dS)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.
        r6z/'endpoint' may not contain a dot '.' character.r=z5'view_func' name may not contain a dot '.' character.cs|jˆˆˆfdˆiˆ—ŽS)Nrw)r<©Ús©r2rrwr1r3r'r-Ú<lambda>¯sýüûz(Blueprint.add_url_rule.<locals>.<lambda>N)rHÚhasattrr=rS)r,r1r2r3rwrr'rzr-r<™s ÿzBlueprint.add_url_rulez2t.Callable[[T_template_filter], T_template_filter])r#r csdddœ‡‡fdd„ }|S)aRegister a template filter, available in any template rendered by the
        application. Equivalent to :meth:`.Flask.template_filter`.
 
        :param name: the optional name of the filter, otherwise the
                     function name will be used.
        r©Úfr csˆj|ˆd|S©Nre)Úadd_app_template_filter©r~rvr'r-Ú    decoratorÃsz0Blueprint.app_template_filter.<locals>.decoratorr'©r,r#r‚r'rvr-Úapp_template_filter¸s zBlueprint.app_template_filterzft.TemplateFilterCallable)r~r#r cs$dddœ‡‡fdd„ }| |¡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.
        r rrTcsˆ|jjjˆpˆj<dSrV)rÚ    jinja_envÚfiltersr=rW©r~r#r'r-Úregister_templateÕsz<Blueprint.add_app_template_filter.<locals>.register_templateN©rZ©r,r~r#rˆr'r‡r-r€És z!Blueprint.add_app_template_filterz.t.Callable[[T_template_test], T_template_test]csdddœ‡‡fdd„ }|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.
        rr}csˆj|ˆd|Sr)Úadd_app_template_testrrvr'r-r‚çsz.Blueprint.app_template_test.<locals>.decoratorr'rƒr'rvr-Úapp_template_testÚs zBlueprint.app_template_testzft.TemplateTestCallablecs$dddœ‡‡fdd„ }| |¡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.
        r rrTcsˆ|jjjˆpˆj<dSrV)rr…Útestsr=rWr‡r'r-rˆûsz:Blueprint.add_app_template_test.<locals>.register_templateNr‰rŠr'r‡r-r‹íszBlueprint.add_app_template_testz2t.Callable[[T_template_global], T_template_global]csdddœ‡‡fdd„ }|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.
        rr}csˆj|ˆd|Sr)Úadd_app_template_globalrrvr'r-r‚ sz0Blueprint.app_template_global.<locals>.decoratorr'rƒr'rvr-Úapp_template_globals zBlueprint.app_template_globalzft.TemplateGlobalCallablecs$dddœ‡‡fdd„ }| |¡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.
        r rrTcsˆ|jjjˆpˆj<dSrV)rr…Úglobalsr=rWr‡r'r-rˆ!sz<Blueprint.add_app_template_global.<locals>.register_templateNr‰rŠr'r‡r-rŽsz!Blueprint.add_app_template_globalrr}cs| ‡fdd„¡ˆS)zLike :meth:`before_request`, but before every request, not only those handled
        by the blueprint. Equivalent to :meth:`.Flask.before_request`.
        cs|jj dg¡ ˆ¡SrV)rrjr:rRrxrr'r-r{,óz.Blueprint.before_app_request.<locals>.<lambda>r‰©r,r~r'rr-Úbefore_app_request&s
ÿzBlueprint.before_app_requestr cs| ‡fdd„¡ˆS)zšLike :meth:`after_request`, but after every request, not only those handled
        by the blueprint. Equivalent to :meth:`.Flask.after_request`.
        cs|jj dg¡ ˆ¡SrV)rrkr:rRrxrr'r-r{6r‘z-Blueprint.after_app_request.<locals>.<lambda>r‰r’r'rr-Úafter_app_request0s
ÿzBlueprint.after_app_requestrcs| ‡fdd„¡ˆS)z Like :meth:`teardown_request`, but after every request, not only those
        handled by the blueprint. Equivalent to :meth:`.Flask.teardown_request`.
        cs|jj dg¡ ˆ¡SrV)rrlr:rRrxrr'r-r{@r‘z0Blueprint.teardown_app_request.<locals>.<lambda>r‰r’r'rr-Úteardown_app_request:s
ÿzBlueprint.teardown_app_requestrcs| ‡fdd„¡ˆS)z¥Like :meth:`context_processor`, but for templates rendered by every view, not
        only by the blueprint. Equivalent to :meth:`.Flask.context_processor`.
        cs|jj dg¡ ˆ¡SrV)rror:rRrxrr'r-r{Lr‘z1Blueprint.app_context_processor.<locals>.<lambda>r‰r’r'rr-Úapp_context_processorDs
ÿzBlueprint.app_context_processorztype[Exception] | intz.t.Callable[[T_error_handler], T_error_handler])rhr csdddœ‡‡fdd„ }|S)z–Like :meth:`errorhandler`, but for every request, not only those handled by
        the blueprint. Equivalent to :meth:`.Flask.errorhandler`.
        rr}csˆ ‡‡fdd„¡ˆS)Ncs|j ˆ¡ˆƒSrV)rZ errorhandlerrx)rhr~r'r-r{Yr‘z?Blueprint.app_errorhandler.<locals>.decorator.<locals>.<lambda>r‰r©rhr,rr-r‚Xsz-Blueprint.app_errorhandler.<locals>.decoratorr')r,rhr‚r'r—r-Úapp_errorhandlerPszBlueprint.app_errorhandlerrcs| ‡fdd„¡ˆS)zªLike :meth:`url_value_preprocessor`, but for every request, not only those
        handled by the blueprint. Equivalent to :meth:`.Flask.url_value_preprocessor`.
        cs|jj dg¡ ˆ¡SrV)rrnr:rRrxrr'r-r{fr‘z6Blueprint.app_url_value_preprocessor.<locals>.<lambda>r‰r’r'rr-Úapp_url_value_preprocessor^s
ÿz$Blueprint.app_url_value_preprocessorrcs| ‡fdd„¡ˆS)z–Like :meth:`url_defaults`, but for every request, not only those handled by
        the blueprint. Equivalent to :meth:`.Flask.url_defaults`.
        cs|jj dg¡ ˆ¡SrV)rrmr:rRrxrr'r-r{pr‘z,Blueprint.app_url_defaults.<locals>.<lambda>r‰r’r'rr-Úapp_url_defaultsjs
ÿzBlueprint.app_url_defaults)F)NNN)N)N)N)N)N)N)r=r>r?r@rNrr.rPr
rSrZr[r\rsr<r„r€rŒr‹rrŽr“r”r•r–r˜r™ršÚ __classcell__r'r'rKr-rwsv4õ&'
ÿ        ûÿÿÿÿÿÿ               r),Ú
__future__rÚosrÚtÚ collectionsrÚ    functoolsrr%ÚftZscaffoldrrr    r
Ú TYPE_CHECKINGrr ÚCallableZDeferredSetupFunctionÚTypeVarZAfterRequestCallabler ZBeforeRequestCallablerZErrorHandlerCallablerZTeardownCallablerZ TemplateContextProcessorCallablerZTemplateFilterCallablerZTemplateGlobalCallablerZTemplateTestCallablerZURLDefaultCallablerZURLValuePreprocessorCallablerr rr'r'r'r-Ú<module>s<         ÿÿU