;i2ddlmZddlZddlmZddlmZddlmZej dej dej f Z e gd ZGd d ZGd deZdS)) annotationsN)typing) current_app)requestF.)bound)getpostheadoptionsdeleteputtracepatchcleZdZUdZdZded<dZded<gZded<d Zd ed <ddZ e ddZ 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/", 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_optionsz(t.ClassVar[list[t.Callable[..., t.Any]]] decoratorsTzt.ClassVar[bool]init_every_requestreturnft.ResponseReturnValuect)zThe actual view function behavior. Subclasses must override this and return a valid response. Any variables from the URL rule are passed as keyword arguments. )NotImplementedError)selfs ?C:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\flask/views.pydispatch_requestzView.dispatch_requestNs "###namestr class_argst.Any class_kwargsft.RouteCallablec$|jr dfd n|idfd |jr(|_|j_|jD] }||_|_|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. kwargsr#rrc\ji}tj|jdi|SN) view_classr ensure_syncr)r'rr"r$views rr-zView.as_view..viewjsH&t#/F{.t/DEEOOOOOrcBtjjdi|Sr))rr,r)r'rs rr-zView.as_view..viewss'E{.t/DEEOOOOOrr'r#rr)rr__name__ __module__r+__doc__rr)clsr r"r$ decoratorrr-s `` @@ras_viewz View.as_viewUs&  ! P P P P P P P P P P3 3l33D P P P P P P > ' DM!nDO ^ ' '  y { .{ ),)F& r)rr)r r!r"r#r$r#rr%) r0r1 __qualname__r2r__annotations__rrrr classmethodr5r*rrrrsD59G8888 :>====<>J====,0////$$$$111[111rrc,eZdZdZd fd Zd dZxZS) MethodViewaDispatches 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'r#rNonec ntjdi|d|jvrt}|jD]-}t |ddr||j.tD]9}t||r'| | :|r ||_dSdSdS)Nrr*) super__init_subclass____dict__set __bases__getattrupdaterhttp_method_funcshasattraddupper)r3r'rbasekey __class__s rr>zMethodView.__init_subclass__s!!++F+++ CL ( (eeG  1 14D111NN4<000( - -3$$-KK ,,, &%  ) ( & &rrc t|tjd}|!tjdkrt|dd}|Jdtjt j|di|S)NHEADr zUnimplemented method r*)rBrmethodlowerrr,)rr'meths rrzMethodView.dispatch_requeststW^1133T:: r __classcell__)rJs@rr:r:s[4&&&&&&" 7 7 7 7 7 7 7 7rr:) __future__rrtftglobalsrrTypeVarCallableAnyr frozensetrDrr:r*rrrZs""""""  AIcCJ/000IIII wwwwwwwwt57575757575757575757r