o
    þÞhW$  ã                   @   sØ   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 d d	lmZ e  d
¡ZG dd„ dƒZG dd„ dƒZG dd„ dƒZG dd„ deeeƒZG dd„ deƒZdS )é    N)ÚiscoroutinefunctionÚmarkcoroutinefunction)ÚImproperlyConfigured)ÚHttpResponseÚHttpResponseGoneÚHttpResponseNotAllowedÚHttpResponsePermanentRedirectÚHttpResponseRedirect)ÚTemplateResponse)Úreverse)Úclassonlymethod)Úclassproperty)Úlog_responsezdjango.requestc                   @   s   e Zd ZdZdZdd„ ZdS )ÚContextMixinz
    A default context mixin that passes the keyword arguments received by
    get_context_data() as the template context.
    Nc                 K   s&   |  d| ¡ | jd ur| | j¡ |S )NÚview)Ú
setdefaultÚextra_contextÚupdate)ÚselfÚkwargs© r   úY/var/www/html/premium_crap/venv/lib/python3.10/site-packages/django/views/generic/base.pyÚget_context_data   s   
zContextMixin.get_context_data)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r      s    r   c                   @   s`   e Zd ZdZg d¢Zdd„ Zedd„ ƒZedd„ ƒZ	d	d
„ Z
dd„ Zdd„ Zdd„ Zd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                 K   s"   |  ¡ D ]
\}}t| ||ƒ qdS )z|
        Constructor. Called in the URLconf; can contain helpful extra
        keyword arguments, and other things.
        N)ÚitemsÚsetattr)r   r   ÚkeyÚvaluer   r   r   Ú__init__6   s   ÿzView.__init__c                    sZ   ‡ fdd„ˆ j D ƒ}|sdS t|d ƒ‰t‡fdd„|dd … D ƒƒs+tˆ j› d�ƒ‚ˆS )	Nc                    s(   g | ]}|d krt ˆ |ƒrtˆ |ƒ‘qS )r$   )ÚhasattrÚgetattr)Ú.0Úmethod)Úclsr   r   Ú
<listcomp>B   s
    þz&View.view_is_async.<locals>.<listcomp>Fr   c                 3   s   � | ]	}t |ƒˆ kV  qd S ©N)r   )r-   Úh)Úis_asyncr   r   Ú	<genexpr>J   s   € z%View.view_is_async.<locals>.<genexpr>é   z4 HTTP handlers must either be all sync or all async.)Úhttp_method_namesr   Úallr   r   )r/   Úhandlersr   )r/   r3   r   Úview_is_async@   s   
þ
ÿzView.view_is_asyncc                    s˜   ˆD ]}|ˆ j v rtd|ˆ jf ƒ‚tˆ |ƒs tdˆ j|f ƒ‚q‡ ‡fdd„}ˆ |_ˆ|_ˆ j|_ˆ j|_ˆ jj	|_	|j
 ˆ jj
¡ ˆ jrJt|ƒ |S )z0Main entry point for a request-response process.zAThe method name %s is not accepted as a keyword argument to %s().zm%s() received an invalid keyword %r. as_view only accepts arguments that are already attributes of the class.c                    sV   ˆ di ˆ¤Ž}|j | g|¢R i |¤Ž t|dƒstdˆ j ƒ‚|j| g|¢R i |¤ŽS )NÚrequestz\%s instance has no 'request' attribute. Did you override setup() and forget to call super()?r   )Úsetupr+   ÚAttributeErrorr   Údispatch)r:   Úargsr   r   ©r/   Ú
initkwargsr   r   r   a   s   
ÿÿzView.as_view.<locals>.view)r6   Ú	TypeErrorr   r+   Ú
view_classÚview_initkwargsr   r   r=   Ú__annotations__Ú__dict__r   r9   r   )r/   r@   r(   r   r   r?   r   Úas_viewQ   s0   
ÿÿ
þÿÿ

zView.as_viewc                 O   s2   t | dƒrt | dƒs| j| _|| _|| _|| _dS )z1Initialize attributes shared by all view methods.r   r#   N)r+   r   r#   r:   r>   r   ©r   r:   r>   r   r   r   r   r;   ~   s
   
z
View.setupc                 O   sB   |j  ¡ | jv rt| |j  ¡ | jƒ}n| j}||g|¢R i |¤ŽS r1   )r.   Úlowerr6   r,   Úhttp_method_not_allowed)r   r:   r>   r   Úhandlerr   r   r   r=   †   s   ÿzView.dispatchc                    s>   t |  ¡ ƒ‰ td|j|jˆ |d� | jr‡ fdd„}|ƒ S ˆ S )NzMethod Not Allowed (%s): %s©Úresponser:   c                   “   ó   �ˆ S r1   r   r   ©rL   r   r   Úfuncž   ó   €z*View.http_method_not_allowed.<locals>.func)r   Ú_allowed_methodsr   r.   Úpathr9   ©r   r:   r>   r   rO   r   rN   r   rI   ’   s   ûzView.http_method_not_allowedc                    s@   t ƒ ‰ d |  ¡ ¡ˆ jd< dˆ jd< | jr‡ fdd„}|ƒ S ˆ S )z8Handle responding to requests for the OPTIONS HTTP verb.z, ÚAllowÚ0zContent-Lengthc                   “   rM   r1   r   r   rN   r   r   rO   ­   rP   zView.options.<locals>.func)r   ÚjoinrQ   Úheadersr9   rS   r   rN   r   r$   ¥   s   
zView.optionsc                    s   ‡ fdd„ˆ j D ƒS )Nc                    s   g | ]}t ˆ |ƒr| ¡ ‘qS r   )r+   Úupper)r-   Úm©r   r   r   r0   µ   s    z)View._allowed_methods.<locals>.<listcomp>)r6   rZ   r   rZ   r   rQ   ´   s   zView._allowed_methodsN)r   r   r   r   r6   r*   r   r9   r   rF   r;   r=   rI   r$   rQ   r   r   r   r   r   %   s    


,r   c                   @   s0   e Zd ZdZdZdZeZdZdd„ Z	dd„ Z
dS )ÚTemplateResponseMixinz.A mixin that can be used to render a template.Nc                 K   s0   |  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)r:   ÚtemplateÚcontextÚusingNr   )r   r\   Úresponse_classr:   Úget_template_namesÚtemplate_engine)r   r^   Úresponse_kwargsr   r   r   Úrender_to_responseÀ   s   üûz(TemplateResponseMixin.render_to_responsec                 C   s   | j du r	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   rZ   r   r   r   ra   Ð   s
   
ÿz(TemplateResponseMixin.get_template_names)r   r   r   r   re   rb   r
   r`   r\   rd   ra   r   r   r   r   r[   ¸   s    r[   c                   @   s   e Zd ZdZdd„ ZdS )ÚTemplateViewzT
    Render a template. Pass keyword arguments from the URLconf to the context.
    c                 O   s   | j di |¤Ž}|  |¡S )Nr   )r   rd   )r   r:   r>   r   r^   r   r   r   r   ã   s   
zTemplateView.getN)r   r   r   r   r   r   r   r   r   rf   Þ   s    rf   c                   @   s`   e Zd ZdZdZdZdZdZdd„ Zdd„ Z	dd	„ Z
d
d„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚRedirectViewz&Provide a redirect on any GET request.FNc                 O   sX   | j r	| j | }n| jrt| j||d�}ndS | jj dd¡}|r*| jr*d||f }|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.
        )r>   r   NÚQUERY_STRINGÚ z%s?%s)ÚurlÚpattern_namer   r:   ÚMETAr   Úquery_string)r   r>   r   rj   r   r   r   Úget_redirect_urlð   s   
zRedirectView.get_redirect_urlc                 O   sF   | j |i |¤Ž}|r| jrt|ƒS t|ƒS tƒ }td|j||d� |S )NzGone: %srK   )rn   Ú	permanentr   r	   r   r   rR   )r   r:   r>   r   rj   rL   r   r   r   r     s   zRedirectView.getc                 O   ó   | j |g|¢R i |¤ŽS r1   ©r   rG   r   r   r   r#     ó   zRedirectView.headc                 O   rp   r1   rq   rG   r   r   r   r     rr   zRedirectView.postc                 O   rp   r1   rq   rG   r   r   r   r$     rr   zRedirectView.optionsc                 O   rp   r1   rq   rG   r   r   r   r"     rr   zRedirectView.deletec                 O   rp   r1   rq   rG   r   r   r   r      rr   zRedirectView.putc                 O   rp   r1   rq   rG   r   r   r   r!     rr   zRedirectView.patch)r   r   r   r   ro   rj   rk   rm   rn   r   r#   r   r$   r"   r    r!   r   r   r   r   rg   è   s    rg   )ÚloggingÚasgiref.syncr   r   Údjango.core.exceptionsr   Údjango.httpr   r   r   r   r	   Údjango.template.responser
   Údjango.urlsr   Údjango.utils.decoratorsr   Údjango.utils.functionalr   Údjango.utils.logr   Ú	getLoggerÚloggerr   r   r[   rf   rg   r   r   r   r   Ú<module>   s     
 &
