î
ªÍ XC
  ã               @   s8   d  d l  Z  d  d l m Z d d „  Z d d „  Z d S)é    N)ÚHttpRequestc                 s   ‡  f d d †  } | S)a§  
    Indicates 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.

    Two forms are accepted:

    * 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 it is assumed that
      all variables are considered sensitive:

        @sensitive_variables()
        def my_function()
            ...
    c                s+   t  j ˆ  ƒ ‡  ‡ ‡ f d d †  ƒ ‰ ˆ S)Nc                 s(   ˆ r ˆ ˆ _  n	 d ˆ _  ˆ  |  | Ž  S)NÚ__ALL__)Úsensitive_variables)Ú	func_argsZfunc_kwargs)ÚfuncÚsensitive_variables_wrapperÚ	variables© úK/home/ubuntu/projects/ifolica/build/django/django/views/decorators/debug.pyr      s    	zKsensitive_variables.<locals>.decorator.<locals>.sensitive_variables_wrapper)Ú	functoolsÚwraps)r   )r   )r   r   r
   Ú	decorator   s    'z&sensitive_variables.<locals>.decoratorr	   )r   r   r	   )r   r
   r      s    	r   c                 s   ‡  f d d †  } | S)a¨  
    Indicates 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.

    Two forms are accepted:

    * 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 it is assumed that
      all parameters are considered sensitive:

        @sensitive_post_parameters()
        def my_view(request)
            ...
    c                s(   t  j ˆ  ƒ ‡ ‡  f d d †  ƒ } | S)Nc                sF   t  |  t ƒ s t d ƒ ‚ ˆ  r- ˆ  |  _ n	 d |  _ ˆ |  | | Ž S)Nzsensitive_post_parameters didn't receive an HttpRequest. If you are decorating a classmethod, be sure to use @method_decorator.r   )Ú
isinstancer   ÚAssertionErrorÚsensitive_post_parameters)ÚrequestÚargsÚkwargs)Ú
parametersÚviewr	   r
   Ú!sensitive_post_parameters_wrapperA   s    		zWsensitive_post_parameters.<locals>.decorator.<locals>.sensitive_post_parameters_wrapper)r   r   )r   r   )r   )r   r
   r   @   s    $z,sensitive_post_parameters.<locals>.decoratorr	   )r   r   r	   )r   r
   r   )   s    r   )r   Zdjango.httpr   r   r   r	   r	   r	   r
   Ú<module>   s   #