
    h#                      x    S r SSKJrJrJr  SSKJr   " S S\5      rS r	S r
SS jrS	 rS
 rS rS rS rS rg)zCFunctions that help with dynamically creating decorators for views.    )partialupdate_wrapperwraps)iscoroutinefunctionc                   ,   ^  \ rS rSrSU 4S jjrSrU =r$ )classonlymethod   c                 >   > Ub  [        S5      e[        TU ]	  X5      $ )Nz=This method is available only on the class, not on instances.)AttributeErrorsuper__get__)selfinstancecls	__class__s      I/var/www/html/env/lib/python3.13/site-packages/django/utils/decorators.pyr   classonlymethod.__get__	   s*     O  wx--     N)__name__
__module____qualname____firstlineno__r   __static_attributes____classcell__)r   s   @r   r   r      s    . .r   r   c                 *    US 5       n[        X5        g )Nc                      g r   r   )argskwargss     r   dummy%_update_method_wrapper.<locals>.dummy   s    r   )r   )_wrapper	decoratorr!   s      r   _update_method_wrapperr%      s        8#r   c                    ^ ^ [        T S5      (       a	  T SSS2   m OT /m U U4S jnT  H  n[        X#5        M     [        UT5        U$ )z~
Decorate `method` with one or more function decorators. `decorators` can be
a single decorator or an iterable of decorators.
__iter__Nc           
         > [        T5      " [        TR                  U [        U 5      5      5      5      nT H  nU" U5      nM     U" U0 UD6$ r   )r   r   r   type)r   r   r    bound_methoddec
decoratorsmethods        r   r#   !_multi_decorate.<locals>._wrapper(   sK    
 V}WV^^D$t*-M%NOC|,L T,V,,r   )hasattrr%   r   )r-   r.   r#   r,   s   ``  r   _multi_decorater1      sS    
 z:&&  "%
 \
- x-  8V$Or   c                    ^ ^ U U4S jn[        T S5      (       d  [        UT 5        [        T S5      (       a  T OT R                  nSUR                  -  Ul        U$ )z6
Convert a function decorator into a method decorator
c           	      <  > [        U [        5      (       d  [        TU 5      $ T(       a  [        U T5      (       d  [	        SU < ST< S35      e[        U T5      n[        U5      (       d  [        ST< SU < SU< S35      e[        TU5      n[        U TU5        U $ )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*   r1   r0   
ValueErrorgetattrcallable	TypeErrorsetattr)objr.   r#   r$   names      r   _dec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))r0   r   r   r   )r$   r;   r<   r:   s   ``  r   method_decoratorr>   :   sO    ( 9j))tY'y*55)9;N;NC*S\\9DMKr   c                     [        U 5      $ )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_argsrD   _   s     %%566r   c                 "    [        U 5      " 5       $ )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.
r@   rB   s    r   decorator_from_middlewarerF   o   s     %%5688r   c                    ^  U 4S jnU$ )Nc                     >^ ^ U UU4S jnU$ )Nc                    >^ ^^^^ T" T /TQ70 TD6mUU 4S jmU4S jmU4S jm[        T 5      (       a
  UUUU 4S jnO	UUUU 4S jn[        T 5      " U5      $ )Nc                    > [        TS5      (       a  TR                  U 5      nUb  U$ [        TS5      (       a  TR                  U TX5      nUb  U$ g )Nprocess_requestprocess_view)r0   rK   rL   )requestr   r    result
middleware	view_funcs       r   _pre_process_requestdmake_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._pre_process_request}   s[    :'899'77@F)%:~66'44WiVF)%r   c                 T   > [        TS5      (       a  TR                  X5      nUb  U$ e )Nprocess_exception)r0   rT   )rM   	exceptionrN   rO   s      r   _process_exceptionbmake_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._process_exception   s/    :':;;'99'MF)%r   c                 B  >^  [        US5      (       ah  [        UR                  5      (       aN  [        TS5      (       a  TR                  T U5      n[        TS5      (       a  UU 4S jnUR	                  U5        U$ [        TS5      (       a  TR                  T U5      $ U$ )Nrenderprocess_template_responseprocess_responsec                 (   > TR                  TU 5      $ r   )r[   )responserO   rM   s    r   callbackwmake_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._post_process_request.<locals>.callback   s    #-#>#>w#QQr   )r0   r7   rY   rZ   add_post_render_callbackr[   )rM   r]   r^   rO   s   `  r   _post_process_requestemake_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._post_process_request   s    8X..8HOO3L3Lz+FGG#-#G#G#X$
 z+=>>R !99(C   z+=>>)::7HMMr   c                    >#    T" U /UQ70 UD6nUb  U$  T	" U /UQ70 UD6I S h  vN nT" U W5      $  N! [          a  nT" X5      nUb  Us S nA$  S nAN,S nAff = f7fr   	Exception
rM   r   r    rN   r]   era   rQ   rV   rP   s
         r   _view_wrapper]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$ *!3G!?!-#)M .*s<   A5 35 	A5 
AAA
AAAc                    > T" U /UQ70 UD6nUb  U$  T	" U /UQ70 UD6nT" U W5      $ ! [          a  nT" X5      nUb  Us S nA$  S nAN*S nAff = fr   rd   rf   s
         r   rh   ri      sv    1'KDKFKF)%*#,W#Ft#Fv#F 1(CC % *!3G!?!-#)M .*s   ) 
AA
A
A)r   r   )	rP   rh   ra   rQ   rV   rO   m_argsm_kwargsrC   s	   ` @@@@r   
_decoratorFmake_middleware_decorator.<locals>._make_decorator.<locals>._decoratorz   s]    ))IfIIJ	 & #9--D D D D #M22r   r   )rk   rl   rm   rC   s   `` r   _make_decorator2make_middleware_decorator.<locals>._make_decoratory   s    H	3T r   r   )rC   ro   s   ` r   rA   rA   x   s    KZ r   c                 "    SU l         SU l        U $ )z^
Mark a middleware factory as returning a hybrid middleware supporting both
types of request.
Tsync_capableasync_capablefuncs    r   sync_and_async_middlewarerw      s    
 DDKr   c                 "    SU l         SU l        U $ )zP
Mark a middleware factory as returning a sync middleware.
This is the default.
TFrr   ru   s    r   sync_only_middlewarery      s    
 DDKr   c                 "    SU l         SU l        U $ )z;Mark a middleware factory as returning an async middleware.FTrr   ru   s    r   async_only_middlewarer{      s    DDKr   N) )__doc__	functoolsr   r   r   asgiref.syncr   classmethodr   r%   r1   r>   rD   rF   rA   rw   ry   r{   r   r   r   <module>r      sM    E 4 4 ,.k .$>"J7 9Nbr   