
    k"g;$                        d dl Z d dlmZ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 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)iscoroutinefunctionmarkcoroutinefunction)ImproperlyConfigured)HttpResponseHttpResponseGoneHttpResponseNotAllowedHttpResponsePermanentRedirectHttpResponseRedirect)TemplateResponse)reverse)classonlymethod)classpropertyz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     R/var/www/html/djangosite/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                   \    e Zd ZdZg dZd Ze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__5   s)     !,,. 	&JCD#u%	&r   c                     | j                   D cg c]  }|dk7  rt        | |      rt        | |      ! }}|syt        |d         t	        fd|dd  D              st        | j                   d      S c c}w )Nr(   Fr   c              3   :   K   | ]  }t        |      k(    y wN)r   ).0his_asyncs     r   	<genexpr>z%View.view_is_async.<locals>.<genexpr>I   s     L!&q)X5Ls      z4 HTTP handlers must either be all sync or all async.)http_method_nameshasattrgetattrr   allr   r   )clsmethodhandlersr5   s      @r   view_is_asynczView.view_is_async?   s     //
)#V(< C 
 

 &x{3Lx|LL&##$ %   
s   $A8c                     D ]S  }| j                   v rt        d|d j                  d      t         |      r:t         j                  d|d        fd} |_        |_         j                  |_         j                  |_         j                  j                  |_	        |j                  j                   j                  j                          j                  rt        |       |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   )setupr9   AttributeErrorr   dispatch)rB   argsr   r   r<   
initkwargss       r   r   zView.as_view.<locals>.view`   sn    $$DDJJw0004+$:<?LLI  !4==:4:6::r   )r8   	TypeErrorr   r9   
view_classview_initkwargsr   r   rE   __annotations____dict__r   r?   r   )r<   rG   r-   r   s   ``  r   as_viewzView.as_viewP   s      	Cc+++"%s||5  3$ 36,,E 		; )
 {{.."||;; 	S\\223 !$'r   c                     t        | d      rt        | d      s| j                  | _        || _        || _        || _        y)z1Initialize attributes shared by all view methods.r"   r'   N)r9   r"   r'   rB   rF   r   r   rB   rF   r   s       r   rC   z
View.setup}   s5    4f(=DI	r   c                     |j                   j                         | j                  v r0t        | |j                   j                         | j                        }n| j                  } ||g|i |S r2   )r=   lowerr8   r:   http_method_not_allowed)r   rB   rF   r   handlers        r   rE   zView.dispatch   se     >>!T%;%;;gnn**,d.J.JG 22Gw0000r   c                     t         j                  d|j                  |j                  d|d       t	        | j                               | j                  rfd} |       S S )NzMethod Not Allowed (%s): %si  status_coderB   extrac                     K    S wr2   r   responses   r   funcz*View.http_method_not_allowed.<locals>.func           )loggerwarningr=   pathr   _allowed_methodsr?   r   rB   rF   r   r\   r[   s        @r   rR   zView.http_method_not_allowed   s^    )NNLL"%':	 	 	
 *$*?*?*AB  6MOr   c                     t               dj                  | j                               j                  d<   dj                  d<   | j                  rfd} |       S S )z8Handle responding to requests for the OPTIONS HTTP verb.z, Allow0zContent-Lengthc                     K    S wr2   r   rZ   s   r   r\   zView.options.<locals>.func   r]   r^   )r   joinrb   headersr?   rc   s        @r   r(   zView.options   sY    >$(IId.C.C.E$F!-0)*  6MOr   c                 v    | j                   D cg c]  }t        | |      s|j                         ! c}S c c}w r2   )r8   r9   upper)r   ms     r   rb   zView._allowed_methods   s+    #'#9#9NaWT1=M	NNNs   66N)r   r   r   r   r8   r/   r   r?   r   rM   rC   rE   rR   r(   rb   r   r   r   r!   r!   $   sW    
	&    * *X
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)rB   templatecontextusingr   )r   rp   response_classrB   get_template_namestemplate_engine)r   rr   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   ru   z(TemplateResponseMixin.get_template_names   s4    
 %&Q 
 &&''r   )r   r   r   r   rz   rv   r   rt   rp   rx   ru   r   r   r   rn   rn      s#    8MO%NL
 (r   rn   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   rx   )r   rB   rF   r   rr   s        r   r"   zTemplateView.get   s(    '$''1&1&&w//r   N)r   r   r   r   r"   r   r   r   r|   r|      s    0r   r|   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.
        )rF   r   NQUERY_STRING ?)urlpattern_namer   rB   METAr"   query_string)r   rF   r   r   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  rU   rW   )r   	permanentr	   r
   r_   r`   ra   r   )r   rB   rF   r   r   s        r   r"   zRedirectView.get   sf    #d##T4V4~~4S99+C00NNGLLPW0X   $%%r   c                 .     | j                   |g|i |S r2   r"   rO   s       r   r'   zRedirectView.head      txx1$1&11r   c                 .     | j                   |g|i |S r2   r   rO   s       r   r#   zRedirectView.post  r   r   c                 .     | j                   |g|i |S r2   r   rO   s       r   r(   zRedirectView.options  r   r   c                 .     | j                   |g|i |S r2   r   rO   s       r   r&   zRedirectView.delete  r   r   c                 .     | j                   |g|i |S r2   r   rO   s       r   r$   zRedirectView.put  r   r   c                 .     | j                   |g|i |S r2   r   rO   s       r   r%   zRedirectView.patch  r   r   )r   r   r   r   r   r   r   r   r   r"   r'   r#   r(   r&   r$   r%   r   r   r   r   r      sA    0I
CLL$&222222r   r   )loggingasgiref.syncr   r   django.core.exceptionsr   django.httpr   r   r   r	   r
   django.template.responser   django.urlsr   django.utils.decoratorsr   django.utils.functionalr   	getLoggerr_   r   r!   rn   r|   r   r   r   r   <module>r      sz     C 7  6  3 1			+	, OO OOd#( #(L0(, 0724 72r   