zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
U
ß=®d…ã    @srddlmZddlZddlmZddlmZddlmZe    ddd    d
d d d dgƒZ
Gdd„dƒZ Gdd„de ƒZ dS)é)Ú annotationsNé)Útyping)Ú current_app)ÚrequestÚgetÚpostÚheadÚoptionsÚdeleteÚputÚtraceÚpatchc@sheZdZUdZdZded<dZded<gZded<d    Zd
ed <d d œdd„Z    e
dddddœdd„ƒZ dS)ÚViewaSubclass this class and override :meth:`dispatch_request` to
    create a generic class-based view. Call :meth:`as_view` to create a
    view function that creates an instance of the class with the given
    arguments and calls its ``dispatch_request`` method with any URL
    variables.
 
    See :doc:`views` for a detailed guide.
 
    .. code-block:: python
 
        class Hello(View):
            init_every_request = False
 
            def dispatch_request(self, name):
                return f"Hello, {name}!"
 
        app.add_url_rule(
            "/hello/<name>", view_func=Hello.as_view("hello")
        )
 
    Set :attr:`methods` on the class to change what methods the view
    accepts.
 
    Set :attr:`decorators` on the class to apply a list of decorators to
    the generated view function. Decorators applied to the class itself
    will not be applied to the generated view function!
 
    Set :attr:`init_every_request` to ``False`` for efficiency, unless
    you need to store request-global data on ``self``.
    Nz$t.ClassVar[t.Collection[str] | None]Úmethodszt.ClassVar[bool | None]Úprovide_automatic_optionszt.ClassVar[list[t.Callable]]Ú
decoratorsTzt.ClassVar[bool]Úinit_every_requestúft.ResponseReturnValue)ÚreturncCs
tƒ‚dS)z·The actual view function behavior. Subclasses must override
        this and return a valid response. Any variables from the URL
        rule are passed as keyword arguments.
        N)ÚNotImplementedError©Úself©rúBd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\flask/views.pyÚdispatch_requestMszView.dispatch_requestÚstrút.Anyzft.RouteCallable)ÚnameÚ
class_argsÚ class_kwargsrcs–|jr dddœ‡‡‡fdd„ ‰n|ˆˆŽ‰dddœ‡fdd„ ‰|jrf|ˆ_|jˆ_|jD] }|ˆƒ‰qX|ˆ_|ˆ_|jˆ_|jˆ_|jˆ_|jˆ_ˆS)afConvert the class into a view function that can be registered
        for a route.
 
        By default, the generated view will create a new instance of the
        view class for every request and call its
        :meth:`dispatch_request` method. If the view class sets
        :attr:`init_every_request` to ``False``, the same instance will
        be used for every request.
 
        Except for ``name``, all other arguments passed to this method
        are forwarded to the view class ``__init__`` method.
 
        .. versionchanged:: 2.2
            Added the ``init_every_request`` class attribute.
        rr©ÚkwargsrcsˆjˆˆŽ}t |j¡f|ŽS©N)Ú
view_classrÚ ensure_syncr)r"r)rr Úviewrrr&is
ÿzView.as_view.<locals>.viewcst ˆj¡f|ŽSr#)rr%r)r"rrrr&rs)rrÚ__name__Ú
__module__r$Ú__doc__rr)Úclsrrr Ú    decoratorr)rr rr&rÚas_viewTs 
 
 
z View.as_view) r'r(Ú __qualname__r)rÚ__annotations__rrrrÚ classmethodr,rrrrrs
"   rcs8eZdZdZdddœ‡fdd„ Zdddœdd    „Z‡ZS)
Ú
MethodViewaíDispatches request methods to the corresponding instance methods.
    For example, if you implement a ``get`` method, it will be used to
    handle ``GET`` requests.
 
    This can be useful for defining a REST API.
 
    :attr:`methods` is automatically set based on the methods defined on
    the class.
 
    See :doc:`views` for a detailed guide.
 
    .. code-block:: python
 
        class CounterAPI(MethodView):
            def get(self):
                return str(session.get("counter", 0))
 
            def post(self):
                session["counter"] = session.get("counter", 0) + 1
                return redirect(url_for("counter"))
 
        app.add_url_rule(
            "/counter", view_func=CounterAPI.as_view("counter")
        )
    rÚNoner!c srtƒjf|Žd|jkrntƒ}|jD]}t|ddƒr$| |j¡q$tD]}t    ||ƒrF| 
|  ¡¡qF|rn||_dS)Nr) ÚsuperÚ__init_subclass__Ú__dict__ÚsetÚ    __bases__ÚgetattrÚupdaterÚhttp_method_funcsÚhasattrÚaddÚupper)r*r"rÚbaseÚkey©Ú    __class__rrr3¤s
 
 
zMethodView.__init_subclass__rcKsXt|tj ¡dƒ}|dkr0tjdkr0t|ddƒ}|dk    sHtdtj›ƒ‚t |¡f|ŽS)NÚHEADrzUnimplemented method )r7rÚmethodÚlowerÚAssertionErrorrr%)rr"Úmethrrrrµs
 zMethodView.dispatch_request)r'r(r-r)r3rÚ __classcell__rrr?rr0‰sr0) Ú
__future__rrÚtÚÚftÚglobalsrrÚ    frozensetr9rr0rrrrÚ<module>s    ÿz