
    h[                         d dl Z d dlmZ d dlmZ d dlmZmZmZm	Z	m
Z
 d dlmZ d dlmZ d dlmZ  e j"                  d      Z G d	 d
      Z G d d      Z G d d      Z G d deee      Z G d de      Zy)    N)update_wrapper)ImproperlyConfigured)HttpResponseHttpResponseGoneHttpResponseNotAllowedHttpResponsePermanentRedirectHttpResponseRedirect)TemplateResponse)reverse)classonlymethodzdjango.requestc                       e Zd ZdZdZd Zy)ContextMixinz
    A default context mixin that passes the keyword arguments received by
    get_context_data() as the template context.
    Nc                 x    |j                  d|        | j                  |j                  | j                         |S )Nview)
setdefaultextra_contextupdate)selfkwargss     \/var/www/html/ranktracker/api/venv/lib/python3.12/site-packages/django/views/generic/base.pyget_context_datazContextMixin.get_context_data   s5    &$')MM$,,-    )__name__
__module____qualname____doc__r   r    r   r   r   r      s     Mr   r   c                   L    e Zd ZdZg dZd Zed        Zd Zd Z	d Z
d Zd	 Zy
)Viewz}
    Intentionally simple parent class for all views. Only implements
    dispatch-by-method and simple sanity checking.
    )getpostputpatchdeleteheadoptionstracec                 N    |j                         D ]  \  }}t        | ||        y)z|
        Constructor. Called in the URLconf; can contain helpful extra
        keyword arguments, and other things.
        N)itemssetattr)r   r   keyvalues       r   __init__zView.__init__&   s)     !,,. 	&JCD#u%	&r   c                 .    D ]S  }| j                   v rt        d|d j                  d      t         |      r:t         j                  d|d        fd} |_        |_        t        | d       t        | j                  d	       |S )
z0Main entry point for a request-response process.zThe method name z* is not accepted as a keyword argument to z().z() received an invalid keyword zJ. as_view only accepts arguments that are already attributes of the class.c                      di } |j                   | g|i | t        |d      st        dj                  z         |j                  | g|i |S )Nrequestz\%s instance has no 'request' attribute. Did you override setup() and forget to call super()?r   )setuphasattrAttributeErrorr   dispatch)r0   argsr   r   cls
initkwargss       r   r   zView.as_view.<locals>.view>   sn    $$DDJJw0004+$:<?LLI  !4==:4:6::r   r   )updated)assigned)http_method_names	TypeErrorr   r2   
view_classview_initkwargsr   r4   )r6   r7   r+   r   s   ``  r   as_viewzView.as_view0   s      		RCc+++"%s||5  3$>AllC!Q R R		R	; ) 	tS"- 	tS\\B7r   c                     t        | d      rt        | d      s| j                  | _        || _        || _        || _        y)z1Initialize attributes shared by all view methods.r    r%   N)r2   r    r%   r0   r5   r   r   r0   r5   r   s       r   r1   z
View.setupR   s5    4f(=DI	r   c                     |j                   j                         | j                  v r0t        | |j                   j                         | j                        }n| j                  } ||g|i |S N)methodlowerr:   getattrhttp_method_not_allowed)r   r0   r5   r   handlers        r   r4   zView.dispatchZ   s`     >>!T%;%;;dGNN$8$8$:D<X<XYG22Gw0000r   c                     t         j                  d|j                  |j                  d|d       t	        | j                               S )NzMethod Not Allowed (%s): %si  status_coder0   extra)loggerwarningrC   pathr   _allowed_methodsr@   s       r   rF   zView.http_method_not_allowedd   s@    )7>>7<<"%': 	 	
 &d&;&;&=>>r   c                 h    t               }dj                  | j                               |d<   d|d<   |S )z8Handle responding to requests for the OPTIONS HTTP verb.z, Allow0zContent-Length)r   joinrP   )r   r0   r5   r   responses        r   r&   zView.optionsk   s5    > IId&;&;&=>%(!"r   c                 v    | j                   D cg c]  }t        | |      s|j                         ! c}S c c}w rB   )r:   r2   upper)r   ms     r   rP   zView._allowed_methodsr   s+    #'#9#9NaWT1=M	NNNs   66N)r   r   r   r   r:   r-   r   r>   r1   r4   rF   r&   rP   r   r   r   r   r      sD    
 ^&  B1?Or   r   c                   ,    e Zd ZdZdZdZeZdZd Z	d Z
y)TemplateResponseMixinz.A mixin that can be used to render a template.Nc                     |j                  d| j                          | j                  d| j                  | j	                         || j
                  d|S )z
        Return a response, using the `response_class` for this view, with a
        template rendered with the given context.

        Pass response_kwargs to the constructor of the response class.
        content_type)r0   templatecontextusingr   )r   r\   response_classr0   get_template_namestemplate_engine)r   r^   response_kwargss      r   render_to_responsez(TemplateResponseMixin.render_to_response}   s]     	"">43D3DE"t"" 
LL,,.&&	

 
 	
r   c                 J    | j                   t        d      | j                   gS )z
        Return a list of template names to be used for the request. Must return
        a list. May not be called if render_to_response() is overridden.
        ztTemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()')template_namer   )r   s    r   ra   z(TemplateResponseMixin.get_template_names   s6    
 %&QR R &&''r   )r   r   r   r   rf   rb   r
   r`   r\   rd   ra   r   r   r   rZ   rZ   v   s#    8MO%NL
 
(r   rZ   c                       e Zd ZdZd Zy)TemplateViewzT
    Render a template. Pass keyword arguments from the URLconf to the context.
    c                 H     | j                   di |}| j                  |      S )Nr   )r   rd   )r   r0   r5   r   r^   s        r   r    zTemplateView.get   s(    '$''1&1&&w//r   N)r   r   r   r   r    r   r   r   rh   rh      s    0r   rh   c                   P    e Zd ZdZdZdZdZdZd Zd Z	d Z
d Zd Zd	 Zd
 Zd Zy)RedirectViewz&Provide a redirect on any GET request.FNc                     | j                   r| j                   |z  }n&| j                  rt        | j                  ||      }ny| j                  j                  j                  dd      }|r| j                  r|d|}|S )z
        Return the URL redirect to. Keyword arguments from the URL pattern
        match generating the redirect request are provided as kwargs to this
        method.
        )r5   r   NQUERY_STRING ?)urlpattern_namer   r0   METAr    query_string)r   r5   r   rp   s       r   get_redirect_urlzRedirectView.get_redirect_url   so     88((V#C$++$vFC||  $$^R8D%% $'C
r   c                      | j                   |i |}|r"| j                  rt        |      S t        |      S t        j                  d|j                  d|d       t               S )NzGone: %si  rI   rK   )rt   	permanentr   r	   rM   rN   rO   r   )r   r0   r5   r   rp   s        r   r    zRedirectView.get   sf    #d##T4V4~~4S99+C00NNGLL&)g>   $%%r   c                 .     | j                   |g|i |S rB   r    r@   s       r   r%   zRedirectView.head       txx1$1&11r   c                 .     | j                   |g|i |S rB   rx   r@   s       r   r!   zRedirectView.post   ry   r   c                 .     | j                   |g|i |S rB   rx   r@   s       r   r&   zRedirectView.options   ry   r   c                 .     | j                   |g|i |S rB   rx   r@   s       r   r$   zRedirectView.delete   ry   r   c                 .     | j                   |g|i |S rB   rx   r@   s       r   r"   zRedirectView.put   ry   r   c                 .     | j                   |g|i |S rB   rx   r@   s       r   r#   zRedirectView.patch   ry   r   )r   r   r   r   rv   rp   rq   rs   rt   r    r%   r!   r&   r$   r"   r#   r   r   r   rk   rk      sA    0I
CLL$&222222r   rk   )logging	functoolsr   django.core.exceptionsr   django.httpr   r   r   r   r	   django.template.responser
   django.urlsr   django.utils.decoratorsr   	getLoggerrM   r   r   rZ   rh   rk   r   r   r   <module>r      sw     $ 7  6  3			+	, UO UOp!( !(H0(, 0724 72r   