
    df                     B    d dl Z d dlmZ d dlmZ d dlmZ i Zd Zd Z	dS )    N)wraps)iscoroutinefunction)HttpRequestc                       t                     dk    r$t           d                   rt          d           fd}|S )a  
    Indicate which variables used in the decorated function are sensitive so
    that those variables can later be treated in a special way, for example
    by hiding them when logging unhandled exceptions.

    Accept two forms:

    * with specified variable names:

        @sensitive_variables('user', 'password', 'credit_card')
        def my_function(user):
            password = user.pass_word
            credit_card = user.credit_card_number
            ...

    * without any specified variable names, in which case consider all
      variables are sensitive:

        @sensitive_variables()
        def my_function()
            ...
       r   zzsensitive_variables() must be called to use it as a decorator, e.g., use @sensitive_variables(), not @sensitive_variables.c                     t                     r  }t          |dd           |j        }t          |dd           	 t          j        |          }|j        j        }t          | d|           }n%# t          $ r t           j
         d          w xY wrt          |<   n'dt          |<   nt                      fd            S )N__wrapped__:z cannot safely be wrapped by @sensitive_variables, make it either non-async or defined in a Python file (not a builtin or from a native extension).__ALL__c                  6    r_         nd_          | i |S )Nr   )sensitive_variables)	func_argsfunc_kwargsfuncsensitive_variables_wrapper	variabless     YD:\Python Project\djangoTemplates\venv\Lib\site-packages\django/views/decorators/debug.pyr   zKsensitive_variables.<locals>.decorator.<locals>.sensitive_variables_wrapperE   s6     PFO/CCFO/CtY6+666    )r   getattrr	   inspectgetfile__code__co_firstlinenohash	TypeError
ValueError__name__*coroutine_functions_to_sensitive_variablesr   )r   wrapped_func	file_pathfirst_line_numberkeyr   r   s   `    @r   	decoratorz&sensitive_variables.<locals>.decorator(   s8   t$$ "	7*.'L,t<<H+7 ,t<<H?#OL99	 %1$9$H!i==*;==>>     } N N N    LBK:3??BK:3?? 4[[7 7 7 7 7 7 [7 +*s   A6 6"Blencallabler   )r   r#   s   ` r   r   r      sa    . 9~~x	!55J
 
 	

%+ %+ %+ %+ %+N r   c                       t                     dk    r$t           d                   rt          d           fd}|S )a  
    Indicate which POST parameters used in the decorated view are sensitive,
    so that those parameters can later be treated in a special way, for example
    by hiding them when logging unhandled exceptions.

    Accept two forms:

    * with specified parameters:

        @sensitive_post_parameters('password', 'credit_card')
        def my_view(request):
            pw = request.POST['password']
            cc = request.POST['credit_card']
            ...

    * without any specified parameters, in which case consider all
      variables are sensitive:

        @sensitive_post_parameters()
        def my_view(request)
            ...
    r   r   zsensitive_post_parameters() must be called to use it as a decorator, e.g., use @sensitive_post_parameters(), not @sensitive_post_parameters.c                      t                     rt                      fd            }nt                      fd            }|S )Nc                    K   t          | t                    st          d          r| _        nd| _         | g|R i | d {V S Nzsensitive_post_parameters didn't receive an HttpRequest object. If you are decorating a classmethod, make sure to use @method_decorator.r   
isinstancer   r   sensitive_post_parametersrequestargskwargs
parametersviews      r   !sensitive_post_parameters_wrapperzWsensitive_post_parameters.<locals>.decorator.<locals>.sensitive_post_parameters_wrappers   s      !';77 #-  
  B8BG558AG5!T';D;;;F;;;;;;;;;r   c                     t          | t                    st          d          r| _        nd| _         | g|R i |S r*   r+   r.   s      r   r4   zWsensitive_post_parameters.<locals>.decorator.<locals>.sensitive_post_parameters_wrapper   sj    !';77 #-  
  B8BG558AG5tG5d555f555r   )r   r   )r3   r4   r2   s   ` r   r#   z,sensitive_post_parameters.<locals>.decoratorp   s    t$$ 	64[[< < < < < [< < 4[[6 6 6 6 6 [6 10r   r$   )r2   r#   s   ` r   r-   r-   R   s`    . :!A 7 7*
 
 	
!1 !1 !1 !1 !1F r   )
r   	functoolsr   asgiref.syncr   django.httpr   r   r   r-    r   r   <module>r:      s{           , , , , , , # # # # # #-/ *D D DNA A A A Ar   