
    g#                      v    d Z ddlmZmZmZ ddlmZ  G d de      Zd Z	d Z
ddZd	 Zd
 Zd Zd Zd Zd Zy)zCFunctions that help with dynamically creating decorators for views.    )partialupdate_wrapperwraps)iscoroutinefunctionc                         e Zd Zd fd	Z xZS )classonlymethodc                 >    |t        d      t        | 	  ||      S )Nz=This method is available only on the class, not on instances.)AttributeErrorsuper__get__)selfinstancecls	__class__s      o/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/utils/decorators.pyr   zclassonlymethod.__get__	   s,     O  wx--    N)__name__
__module____qualname__r   __classcell__)r   s   @r   r   r      s    . .r   r   c                 ,    |d        }t        | |       y )Nc                       y r    )argskwargss     r   dummyz%_update_method_wrapper.<locals>.dummy   s    r   )r   )_wrapper	decoratorr   s      r   _update_method_wrapperr       s"       8U#r   c                      t         d      r	 ddd    n g  fd} D ]  }t        ||        t        |       |S )z
    Decorate `method` with one or more function decorators. `decorators` can be
    a single decorator or an iterable of decorators.
    __iter__Nc           
           t              t        j                  | t        |                         }D ]
  } ||      }  ||i |S r   )r   r   r   type)r   r   r   bound_methoddec
decoratorsmethods        r   r   z!_multi_decorate.<locals>._wrapper(   sM    
 %uV}WV^^D$t*-M%NOC|,L T,V,,r   )hasattrr    r   )r(   r)   r   r'   s   ``  r   _multi_decorater+      sR    
 z:&  "%
 \
- x-  8V$Or   c                       fd}t         d      st        |        t         d      r n j                  }d|j                  z  |_        |S )z>
    Convert a function decorator into a method decorator
    c           	      
   t        | t              st        |       S rt        |       st	        d| dd      t        |       }t        |      st        dd| d|d      t        |      }t        | |       | S )NzQThe keyword argument `name` must be the name of a method of the decorated class: z. Got 'z
' instead.zCannot decorate 'z&' as it isn't a callable attribute of z (z).)	
isinstancer%   r+   r*   
ValueErrorgetattrcallable	TypeErrorsetattr)objr)   r   r   names      r   _deczmethod_decorator.<locals>._decC   s    #t$"9c22d+CFN  d#"C1  #9f5T8$
r   r"   r   zmethod_decorator(%s))r*   r   r   r   )r   r5   r6   r4   s   ``  r   method_decoratorr7   :   sI    ( 9j)tY'y*5)9;N;NC*S\\9DMKr   c                     t        |       S )a<  
    Like decorator_from_middleware, but return a function
    that accepts the arguments to be passed to the middleware_class.
    Use like::

         cache_page = decorator_from_middleware_with_args(CacheMiddleware)
         # ...

         @cache_page(3600)
         def my_view(request):
             # ...
    make_middleware_decoratormiddleware_classs    r   #decorator_from_middleware_with_argsr=   _   s     %%566r   c                 "     t        |              S )z
    Given a middleware class (not an instance), return a view decorator. This
    lets you use middleware functionality on a per-view basis. The middleware
    is created with no params passed.
    r9   r;   s    r   decorator_from_middlewarer?   o   s     7$%5688r   c                       fd}|S )Nc                        fd}|S )Nc                        gi  fdfdfdt               r	 fd}n fd} t               |      S )Nc                     t        d      rj                  |       }||S t        d      rj                  | ||      }||S y )Nprocess_requestprocess_view)r*   rD   rE   )requestr   r   result
middleware	view_funcs       r   _pre_process_requestzdmake_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._pre_process_request}   sW    :'89'77@F)%:~6'44WivVF)%r   c                 J    t        d      rj                  | |      }||S  )Nprocess_exception)r*   rL   )rF   	exceptionrG   rH   s      r   _process_exceptionzbmake_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._process_exception   s.    :':;'99'9MF)%r   c                     t        |d      rXt        |j                        rCt        d      rj                   |      }t        d      r fd}|j	                  |       |S t        d      rj                   |      S |S )Nrenderprocess_template_responseprocess_responsec                 (    j                  |       S r   )rR   )responserH   rF   s    r   callbackzwmake_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._post_process_request.<locals>.callback   s    #-#>#>w#QQr   )r*   r1   rP   rQ   add_post_render_callbackrR   )rF   rT   rU   rH   s   `  r   _post_process_requestzemake_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._post_process_request   s    8X.8HOO3Lz+FG#-#G#G#X$
 z+=>R !99(C   z+=>)::7HMMr   c                    K    | g|i |}||S 	  	| g|i | d {   } |       S 7 # t         $ r} | |      }||cY d }~S Y d }~+d }~ww xY wwr   	Exception
rF   r   r   rG   rT   erW   rJ   rN   rI   s
         r   _view_wrapperz]make_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._view_wrapper   s     1'KDKFKF)%*)27)LT)LV)L#L 1(CC $M$ *!3GQ!?!-#)M .*s<   A4 24 	A4 	AA	A

AAAc                      | g|i |}||S 	  	| g|i |} |       S # t         $ r} | |      }||cY d }~S Y d }~)d }~ww xY wr   rY   r[   s
         r   r]   z]make_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._view_wrapper   sx    1'KDKFKF)%*#,W#Ft#Fv#F 1(CC % *!3GQ!?!-#)M .*s   ( 	AAAA)r   r   )	rI   r]   rW   rJ   rN   rH   m_argsm_kwargsr<   s	   ` @@@@r   
_decoratorzFmake_middleware_decorator.<locals>._make_decorator.<locals>._decoratorz   sV    ))IfIIJ	 & #9-D D D $5#M22r   r   )r_   r`   ra   r<   s   `` r   _make_decoratorz2make_middleware_decorator.<locals>._make_decoratory   s    H	3T r   r   )r<   rb   s   ` r   r:   r:   x   s    KZ r   c                 "    d| _         d| _        | S )zj
    Mark a middleware factory as returning a hybrid middleware supporting both
    types of request.
    Tsync_capableasync_capablefuncs    r   sync_and_async_middlewareri      s    
 DDKr   c                 "    d| _         d| _        | S )z\
    Mark a middleware factory as returning a sync middleware.
    This is the default.
    TFrd   rg   s    r   sync_only_middlewarerk      s    
 DDKr   c                 "    d| _         d| _        | S )z;Mark a middleware factory as returning an async middleware.FTrd   rg   s    r   async_only_middlewarerm      s    DDKr   N) )__doc__	functoolsr   r   r   asgiref.syncr   classmethodr   r    r+   r7   r=   r?   r:   ri   rk   rm   r   r   r   <module>rs      sM    E 4 4 ,.k .$>"J7 9Nbr   