
    2Bf                     |    d dl ZddlmZ ddl mZ  eg d      Z G d d      Z G d d	e      Z	 G d
 dee	      Z
y)    N   )request)ResponseReturnValue)getpostheadoptionsdeleteputtracepatchc            	       "   e Zd ZU dZdZej                  ej                  e      e	d<   dZ
ej                  e   e	d<   g Zej                  ej                     e	d<   defdZeded	ej"                  d
ej"                  dej                  fd       Zy)Viewa  Alternative way to use view functions.  A subclass has to implement
    :meth:`dispatch_request` which is called with the view arguments from
    the URL routing system.  If :attr:`methods` is provided the methods
    do not have to be passed to the :meth:`~flask.Flask.add_url_rule`
    method explicitly::

        class MyView(View):
            methods = ['GET']

            def dispatch_request(self, name):
                return f"Hello {name}!"

        app.add_url_rule('/hello/<name>', view_func=MyView.as_view('myview'))

    When you want to decorate a pluggable view you will have to either do that
    when the view function is created (by wrapping the return value of
    :meth:`as_view`) or you can use the :attr:`decorators` attribute::

        class SecretView(View):
            methods = ['GET']
            decorators = [superuser_required]

            def dispatch_request(self):
                ...

    The decorators stored in the decorators list are applied one after another
    when the view function is created.  Note that you can *not* use the class
    based decorators since those would decorate the view class and not the
    generated view function!
    Nmethodsprovide_automatic_options
decoratorsreturnc                     t               )zSubclasses have to override this method to implement the
        actual view function code.  This method is called with all
        the arguments from the URL rule.
        )NotImplementedError)selfs    K/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/flask/views.pydispatch_requestzView.dispatch_request=   s    
 "##    name
class_argsclass_kwargsc                    dt         j                  dt         j                  dt        ffd| j                  r1|_        | j
                  _        | j                  D ]
  } |       | _        |_        | j                  _        | j
                  _        | j                  _        | j                  _	        S )a  Converts the class into an actual view function that can be used
        with the routing system.  Internally this generates a function on the
        fly which will instantiate the :class:`View` on each request and call
        the :meth:`dispatch_request` method on it.

        The arguments passed to :meth:`as_view` are forwarded to the
        constructor of the class.
        argskwargsr   c                  L     j                   i } |j                  | i |S )N)
view_classr   )r   r   r   r   r   views      r   r"   zView.as_view.<locals>.viewQ   s0    "4??J?,?D(4(($9&99r   )
tAnyr   r   __name__
__module__r!   __doc__r   r   )clsr   r   r   	decoratorr"   s     `` @r   as_viewzView.as_viewD   s    	: 	: 	:3F 	: >> DM!nnDO ^^ '	 ' {{..{{),)F)F&r   )r%   r&   __qualname__r'   r   r#   OptionalListstr__annotations__r   boolr   Callabler   r   classmethodr$   r*    r   r   r   r      s    @ (,GQZZs$+ 37qzz$/6 &(Jqzz"'$"5 $ !!%&UU!<=EE!	
! !r   r   c                   "     e Zd ZdZ fdZ xZS )MethodViewTypezYMetaclass for :class:`MethodView` that determines what methods the view
    defines.
    c                 (   t         |   |||       d|vr|t               }|D ]+  }t        |dd       s|j	                  |j
                         - t        D ].  }t        | |      s|j                  |j                                0 |r|| _        y y y )Nr   )
super__init__setgetattrupdater   http_method_funcshasattraddupper)r(   r   basesdr   basekey	__class__s          r   r8   zMethodViewType.__init__n   s    ua(AeG 14D1NN4<<01 ) -3$KK		,- %  r   )r%   r&   r+   r'   r8   __classcell__)rD   s   @r   r5   r5   i   s    & &r   r5   c                   L    e Zd ZdZdej
                  dej
                  defdZy)
MethodViewa   A class-based view that dispatches request methods to the corresponding
    class methods. For example, if you implement a ``get`` method, it will be
    used to handle ``GET`` requests. ::

        class CounterAPI(MethodView):
            def get(self):
                return session.get('counter', 0)

            def post(self):
                session['counter'] = session.get('counter', 0) + 1
                return 'OK'

        app.add_url_rule('/counter', view_func=CounterAPI.as_view('counter'))
    r   r   r   c                     t        | t        j                  j                         d       }| t        j                  dk(  rt        | dd       }|J dt        j                          ||i |S )NHEADr   zUnimplemented method )r:   r   methodlower)r   r   r   meths       r   r   zMethodView.dispatch_request   sk    tW^^113T: <GNNf44-DK#88J!KKT$V$$r   N)r%   r&   r+   r'   r#   r$   r   r   r3   r   r   rG   rG      s*    	%aee 	%quu 	%AT 	%r   rG   )	metaclass)typingr#   globalsr   r   	frozensetr<   r   typer5   rG   r3   r   r   <module>rR      sE      ' I 
Z Zz&T &6% %r   