
    F dm                         d dl Zddlm Z ddlmZ ddlmZ  eg d          Z G d d          Z	 G d	 d
e	          Z
dS )    N   )typing)current_app)request)getpostheadoptionsdeleteputtracepatchc            	       b   e Zd ZU dZdZej        ej        ej        e	                           e
d<   dZej        ej        e                  e
d<   g Zej        ej        ej                          e
d<   dZej        e         e
d<   dej        fd	Zed
e	dej        dej        dej        fd            ZdS )Viewa  Subclass 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``.
    Nmethodsprovide_automatic_options
decoratorsTinit_every_requestreturnc                     t                      )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    TC:\Users\ChattiNader\Documents\MyHotelMatch\api\dev\Lib\site-packages\flask/views.pydispatch_requestzView.dispatch_requestK   s    
 "###    name
class_argsclass_kwargsc                    | j         r!dt          j        dt          j        ffdn& | i dt          j        dt          j        ffd| j        r(|_        | j        _        | j        D ]} |          | _        |_        | j	        _	        | j        _        | j
        _
        | j        _        S )af  Convert 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   c                  \     j         i } t          j        |j                  di | S N )
view_classr   ensure_syncr   )r    r   r   r   views     r   r&   zView.as_view.<locals>.viewg   sH    &t#/  F{.t/DEEOOOOOr   c                  B     t          j        j                  di | S r"   )r   r%   r   )r    r   s    r   r&   zView.as_view.<locals>.viewp   s'    E{.t/DEEOOOOOr   )r   tAnyftResponseReturnValuer   __name__
__module__r$   __doc__r   r   )clsr   r   r   	decoratorr   r&   s     `` @@r   as_viewzView.as_viewR   s%   & ! 	PPqu P)? P P P P P P P P P 3
3l33DPqu P)? P P P P P P > 	' DM!nDO ^ ' '	 y {.{),)F&r   )r,   r-   __qualname__r.   r   r(   ClassVarOptional
Collectionstr__annotations__r   boolr   ListCallabler   r*   r+   r   classmethodr)   RouteCallabler1   r#   r   r   r   r      s         D :>GQZ
1<#456===
 ?Cqz!*T*:;BBB 24J
16!*-.333 ,0
4(///$""8 $ $ $ $ 11%&U1<=E1		1 1 1 [1 1 1r   r   c                   Z     e Zd ZdZdej        ddf fdZdej        dej        fdZ	 xZ
S )
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    r   Nc                 n    t                      j        di | d| j        vrt                      }| j        D ]-}t          |dd           r|                    |j                   .t          D ]9}t          | |          r'|
                    |                                           :|r|| _        d S d S d S )Nr   r#   )super__init_subclass____dict__set	__bases__getattrupdater   http_method_funcshasattraddupper)r/   r    r   basekey	__class__s        r   rA   zMethodView.__init_subclass__   s    !!++F+++CL((eeG 1 14D11 1NN4<000( - -3$$ -KK		,,, &% )(& &r   c                    t          | t          j                                        d           }|!t          j        dk    rt          | dd           }|J dt          j                     t	          j        |          di |S )NHEADr   zUnimplemented method r#   )rE   r   methodlowerr   r%   )r   r    meths      r   r   zMethodView.dispatch_request   s    tW^1133T:: <GNf444--D!K!K!K,{&t,,66v666r   )r,   r-   r2   r.   r(   r)   rA   r*   r+   r   __classcell__)rM   s   @r   r>   r>      s~         4& &4 & & & & & &"	7 	723I 	7 	7 	7 	7 	7 	7 	7 	7r   r>   )r   r(    r*   globalsr   r   	frozensetrG   r   r>   r#   r   r   <module>rW      s                                IIII  
w w w w w w w wt57 57 57 57 57 57 57 57 57 57r   