
    Evg#                      ~    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dS )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 )classonlymethodNc                 j    |t          d          t                                          ||          S )Nz=This method is available only on the class, not on instances.)AttributeErrorsuper__get__)selfinstancecls	__class__s      T/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/utils/decorators.pyr   zclassonlymethod.__get__	   s8     O   wwx---    N)__name__
__module____qualname__r   __classcell__)r   s   @r   r   r      s=        . . . . . . . . . .r   r   c                 <    |d             }t          | |           d S )Nc                      d S r    )argskwargss     r   dummyz%_update_method_wrapper.<locals>.dummy   s    r   )r   )_wrapper	decoratorr   s      r   _update_method_wrapperr       s5       Y 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                              | t          |                                         }D ]} ||          } ||i |S r   )r   r   r   type)r   r   r   bound_methoddec
decoratorsmethods        r   r   z!_multi_decorate.<locals>._wrapper(   sk    
 %uV}}WV^^D$t**-M-M%N%NOO 	- 	-C3|,,LL|T,V,,,r   )hasattrr    r   )r(   r)   r   r'   s   ``  r   _multi_decorater+      s    
 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          | 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$$ 	3"9c222 	d++ 	*CF33N   d## 	)"ddCCC1   #9f55T8$$$
r   r"   r   zmethod_decorator(%s))r*   r   r   r   )r   r6   r7   r5   s   ``  r   method_decoratorr8   :   st         ( 9j)) (tY'''y*55
N))9;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66r   c                 0     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.
    r:   r<   s    r   decorator_from_middlewarer@   o   s     7$%566888r   c                       fd}|S )Nc                        fd}|S )Nc                        gR i  fdfdfdt                     r	 fd}n fd} t                     |          S )Nc                     t          d          r                    |           }||S t          d          r                    | ||          }||S d S )Nprocess_requestprocess_view)r*   rE   rF   )requestr   r   result
middleware	view_funcs       r   _pre_process_requestzdmake_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._pre_process_request}   so    :'899 &'77@@F)%:~66 &'44WivVVF)%tr   c                 Z    t          d          r                    | |          }||S  )Nprocess_exception)r*   rM   )rG   	exceptionrH   rI   s      r   _process_exceptionzbmake_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._process_exception   s9    :':;; &'99'9MMF)%r   c                 B    t          |d          rft          |j                  rRt          d          r                     |          }t          d          r fd}|                    |           n&t          d          r                     |          S |S )Nrenderprocess_template_responseprocess_responsec                 0                         |           S r   )rS   )responserI   rG   s    r   callbackzwmake_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._post_process_request.<locals>.callback   s    #-#>#>w#Q#QQr   )r*   r2   rQ   rR   add_post_render_callbackrS   )rG   rU   rV   rI   s   `  r   _post_process_requestzemake_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._post_process_request   s    8X.. N8HO3L3L Nz+FGG #-#G#G#X$ $
 z+=>> DR R R R R R !99(CCCz+=>> N)::7HMMMr   c                    K    | g|R i |}||S 	  	| g|R i | d {V }n,# t           $ r} | |          }||cY d }~S Y d }~nd }~ww xY w | |          S r   	Exception
rG   r   r   rH   rU   erX   rK   rO   rJ   s
         r   _view_wrapperz]make_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._view_wrapper   s      11'KDKKKFKKF)%*)27)LT)L)L)LV)L)L#L#L#L#L#L#L$ * * *!3!3GQ!?!?!-#)MMMMMM .----*
 10(CCCs   ( 
AAAAc                      | g|R i |}||S 	  	| g|R i |}n,# t           $ r} | |          }||cY d }~S Y d }~nd }~ww xY w | |          S r   rZ   r\   s
         r   r^   z]make_middleware_decorator.<locals>._make_decorator.<locals>._decorator.<locals>._view_wrapper   s    11'KDKKKFKKF)%*#,9W#Ft#F#F#Fv#F#F$ * * *!3!3GQ!?!?!-#)MMMMMM .----*
 10(CCCs     
A	AA	A	)r   r   )	rJ   r^   rX   rK   rO   rI   m_argsm_kwargsr=   s	   ` @@@@r   
_decoratorzFmake_middleware_decorator.<locals>._make_decorator.<locals>._decoratorz   s   )))IfIIIIIJ	 	 	 	 	 	             & #9-- DD D D D D D D D D D D D D D D D D $5##M222r   r   )r`   ra   rb   r=   s   `` r   _make_decoratorz2make_middleware_decorator.<locals>._make_decoratory   s8    H	3 H	3 H	3 H	3 H	3 H	3 H	3T r   r   )r=   rc   s   ` r   r;   r;   x   s*    K K K K 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_middlewarerj      s    
 DDKr   c                 "    d| _         d| _        | S )z\
    Mark a middleware factory as returning a sync middleware.
    This is the default.
    TFre   rh   s    r   sync_only_middlewarerl      s    
 DDKr   c                 "    d| _         d| _        | S )z;Mark a middleware factory as returning an async middleware.FTre   rh   s    r   async_only_middlewarern      s    DDKr   N)r,   )__doc__	functoolsr   r   r   asgiref.syncr   classmethodr   r    r+   r8   r>   r@   r;   rj   rl   rn   r   r   r   <module>rs      s    E E 4 4 4 4 4 4 4 4 4 4 , , , , , ,. . . . .k . . .$ $ $  >" " " "J7 7 7 9 9 9N N Nb        r   