î
ªÍ Xš  ã               @   sÒ   d  d l  m Z d  d l m Z m Z d  d l m Z m Z e e ƒ Z d e _	 d e _
 Gd d „  d e ƒ Z e e ƒ Z d e _	 d	 e _
 Gd
 d „  d e ƒ Z e e ƒ Z d e _	 d e _
 d d „  Z d S)é    )Úwraps)ÚCsrfViewMiddlewareÚ	get_token)Úavailable_attrsÚdecorator_from_middlewareÚcsrf_protectzË
This decorator adds CSRF protection in exactly the same way as
CsrfViewMiddleware, but it can be used on a per view basis.  Using both, or
using the decorator multiple times, is harmless and efficient.
c               @   s   e  Z d  Z d d „  Z d S)Ú_EnsureCsrfTokenc             C   s   d  S)N© )ÚselfÚrequestÚreasonr	   r	   úJ/home/ubuntu/projects/ifolica/build/django/django/views/decorators/csrf.pyÚ_reject   s    z_EnsureCsrfToken._rejectN)Ú__name__Ú
__module__Ú__qualname__r   r	   r	   r	   r   r      s   r   Úrequires_csrf_tokenz•
Use this decorator on views that need a correct csrf_token available to
RequestContext, but without the CSRF protection that csrf_protect
enforces.
c                   s.   e  Z d  Z d d „  Z ‡  f d d †  Z ‡  S)Ú_EnsureCsrfCookiec             C   s   d  S)Nr	   )r
   r   r   r	   r	   r   r       s    z_EnsureCsrfCookie._rejectc                s/   t  t |  ƒ j | | | | ƒ } t | ƒ | S)N)Úsuperr   Úprocess_viewr   )r
   r   ÚcallbackÚcallback_argsÚcallback_kwargsÚretval)Ú	__class__r	   r   r   #   s    !
z_EnsureCsrfCookie.process_view)r   r   r   r   r   r	   r	   )r   r   r      s   r   Úensure_csrf_cookiez•
Use this decorator to ensure that a view sets a CSRF cookie, whether or not it
uses the csrf_token template tag, or the CsrfViewMiddleware is used.
c                s7   ‡  f d d †  } d | _  t ˆ  d t ˆ  ƒ ƒ| ƒ S)zN
    Marks a view function as being exempt from the CSRF view protection.
    c                 s   ˆ  |  | Ž  S)Nr	   )ÚargsÚkwargs)Ú	view_funcr	   r   Úwrapped_view9   s    z!csrf_exempt.<locals>.wrapped_viewTÚassigned)Úcsrf_exemptr   r   )r   r   r	   )r   r   r!   2   s    	r!   N)Ú	functoolsr   Zdjango.middleware.csrfr   r   Zdjango.utils.decoratorsr   r   r   r   Ú__doc__r   r   r   r   r!   r	   r	   r	   r   Ú<module>   s   						