
     h/$                        d dl Z d dl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dS )    N)ImproperlyConfigured)HttpResponseHttpResponseGoneHttpResponseNotAllowedHttpResponsePermanentRedirectHttpResponseRedirect)TemplateResponse)reverse)classonlymethod)classpropertyzdjango.requestc                       e Zd ZdZdZd ZdS )ContextMixinz
    A default context mixin that passes the keyword arguments received by
    get_context_data() as the template context.
    Nc                 t    |                     d|            | j        |                    | j                   |S )Nview)
setdefaultextra_contextupdate)selfkwargss     U/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/django/views/generic/base.pyget_context_datazContextMixin.get_context_data   s;    &$''')MM$,---    )__name__
__module____qualname____doc__r   r    r   r   r   r      s4         
 M    r   r   c                   j    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dS )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                 \    |                                 D ]\  }}t          | ||           dS )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__4   s>     !,,.. 	& 	&JCD#u%%%%	& 	&r   c                       fd j         D             }|sdS t          j        |d                   t          fd|dd          D                       st	           j         d          S )Nc                 \    g | ](}|d k    t          |          t          |          )S )r&   )hasattrgetattr).0methodclss     r   
<listcomp>z&View.view_is_async.<locals>.<listcomp>@   sG     
 
 
)##V(<(<# C  ###r   Fr   c              3   H   K   | ]}t          j        |          k    V  d S N)asyncioiscoroutinefunction)r2   his_asyncs     r   	<genexpr>z%View.view_is_async.<locals>.<genexpr>H   s3      TT!7.q11X=TTTTTTr      z4 HTTP handlers must either be all sync or all async.)http_method_namesr8   r9   allr   r   )r4   handlersr;   s   ` @r   view_is_asynczView.view_is_async>   s    
 
 
 
/
 
 

  	5.x{;;TTTTxPQPRPR|TTTTT 	&#      r   c                     D ]P}| j         v rt          d|d j        d          t           |          st           j        d|d          Q fd} |_        |_         j        |_         j        |_         j        j	        |_	        |j
                             j        j
                    j        rt          j        j        |_        |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|R i | t          |d          st          dj        z             |j        | g|R i |S )Nrequestz\%s instance has no 'request' attribute. Did you override setup() and forget to call super()?r   )setupr0   AttributeErrorr   dispatch)rD   argsr   r   r4   
initkwargss       r   r   zView.as_view.<locals>.view_   s    3$$$$DDJw00000004++ $:<?LI   !4=:4:::6:::r   )r>   	TypeErrorr   r0   
view_classview_initkwargsr   r   rG   __annotations____dict__r   rA   r8   
coroutines_is_coroutine)r4   rI   r+   r   s   ``  r   as_viewzView.as_viewO   s     	 	Cc+++i"%##s|||5   3$$  36,,,E  	; 	; 	; 	; 	; 	; )
 {."|; 	S\2333  	B!(!3!ADr   c                     t          | d          rt          | d          s| j        | _        || _        || _        || _        dS )z1Initialize attributes shared by all view methods.r    r%   N)r0   r    r%   rD   rH   r   r   rD   rH   r   s       r   rE   z
View.setup|   sG    4 	!f(=(= 	!DI	r   c                     |j                                         | j        v r.t          | |j                                         | j                  }n| j        } ||g|R i |S r7   )r3   lowerr>   r1   http_method_not_allowed)r   rD   rH   r   handlers        r   rG   zView.dispatch   ss     >!!T%;;;gn**,,d.J GG 2Gww0000000r   c                     t                               d|j        |j        d|d           t	          |                                           | j        rfd} |            S S )NzMethod Not Allowed (%s): %si  status_coderD   extrac                     K    S r7   r   responses   r   funcz*View.http_method_not_allowed.<locals>.func         r   )loggerwarningr3   pathr   _allowed_methodsrA   r   rD   rH   r   r`   r_   s        @r   rV   zView.http_method_not_allowed   s    )NL"%'::	 	 	
 	
 	
 *$*?*?*A*ABB 	          466MOr   c                     t                      d                    |                                           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 r7   r   r^   s   r   r`   zView.options.<locals>.func   ra   r   )r   joinre   headersrA   rf   s        @r   r&   zView.options   su    >>$(IId.C.C.E.E$F$F!-0)* 	          466MOr   c                 *      fd j         D             S )Nc                 X    g | ]&}t          |          |                                'S r   )r0   upper)r2   mr   s     r   r5   z)View._allowed_methods.<locals>.<listcomp>   s0    NNNaWT1=M=MN		NNNr   )r>   r   s   `r   re   zView._allowed_methods   s     NNNN4#9NNNNr   N)r   r   r   r   r>   r-   r   rA   r   rQ   rE   rG   rV   r&   re   r   r   r   r   r   #   s         
	 	 	& & &   ]  * * _*X  
1 
1 
1  $  O O O O Or   r   c                   .    e Zd ZdZdZdZeZdZd Z	d Z
dS )TemplateResponseMixinz.A mixin that can be used to render a template.Nc                     |                     d| j                    | j        d| 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)rD   templatecontextusingr   )r   ru   response_classrD   get_template_namestemplate_engine)r   rw   response_kwargss      r   render_to_responsez(TemplateResponseMixin.render_to_response   se     	"">43DEEE"t" 
L,,..&	
 

 
 
 	
r   c                 >    | 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.
        NztTemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()')template_namer   rq   s    r   rz   z(TemplateResponseMixin.get_template_names   s3    
 %&Q  
 &''r   )r   r   r   r   r   r{   r	   ry   ru   r}   rz   r   r   r   rs   rs      sL        88MO%NL
 
 
 ( ( ( ( (r   rs   c                       e Zd ZdZd ZdS )TemplateViewzT
    Render a template. Pass keyword arguments from the URLconf to the context.
    c                 F     | j         di |}|                     |          S )Nr   )r   r}   )r   rD   rH   r   rw   s        r   r    zTemplateView.get   s.    '$'11&11&&w///r   N)r   r   r   r   r    r   r   r   r   r      s-         0 0 0 0 0r   r   c                   R    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dS )RedirectViewz&Provide a redirect on any GET request.FNc                     | j         r| j         |z  }n!| j        rt          | j        ||          }ndS | 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.
        )rH   r   NQUERY_STRING ?)urlpattern_namer
   rD   METAr    query_string)r   rH   r   r   s       r   get_redirect_urlzRedirectView.get_redirect_url   s     8 	(V#CC 	$+$vFFFCC4| $$^R88 	(D% 	( SS$$'C
r   c                      | j         |i |}|r%| j        rt          |          S t          |          S t                              d|j        d|d           t                      S )NzGone: %si  rY   r[   )r   	permanentr   r   rb   rc   rd   r   )r   rD   rH   r   r   s        r   r    zRedirectView.get   s    #d#T4V44 		&~ 14S999+C000NNGLPW0X0X     $%%%r   c                 $     | j         |g|R i |S r7   r    rS   s       r   r%   zRedirectView.head  $    tx1$111&111r   c                 $     | j         |g|R i |S r7   r   rS   s       r   r!   zRedirectView.post  r   r   c                 $     | j         |g|R i |S r7   r   rS   s       r   r&   zRedirectView.options  r   r   c                 $     | j         |g|R i |S r7   r   rS   s       r   r$   zRedirectView.delete  r   r   c                 $     | j         |g|R i |S r7   r   rS   s       r   r"   zRedirectView.put  r   r   c                 $     | j         |g|R i |S r7   r   rS   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      s        00I
CLL  $& & &2 2 22 2 22 2 22 2 22 2 22 2 2 2 2r   r   )r8   loggingdjango.core.exceptionsr   django.httpr   r   r   r   r   django.template.responser	   django.urlsr
   django.utils.decoratorsr   django.utils.functionalr   	getLoggerrb   r   r   rs   r   r   r   r   r   <module>r      s     7 7 7 7 7 7              6 5 5 5 5 5       3 3 3 3 3 3 1 1 1 1 1 1		+	,	,       OO OO OO OO OO OO OO OOd#( #( #( #( #( #( #( #(L0 0 0 0 0(, 0 0 072 72 72 72 724 72 72 72 72 72r   