<s> from django . middleware . csrf import CsrfViewMiddleware <EOL> from django . utils . decorators import decorator_from_middleware , available_attrs <EOL> try : <EOL> from functools import wraps <EOL> except ImportError : <EOL> from django . utils . functional import wraps <EOL> csrf_protect = decorator_from_middleware ( CsrfViewMiddleware ) <EOL> csrf_protect . __name__ = "<STR_LIT>" <EOL> csrf_protect . __doc__ = """<STR_LIT>""" <EOL> class _EnsureCsrfToken ( CsrfViewMiddleware ) : <EOL> def _reject ( self , request , reason ) : <EOL> return None <EOL> requires_csrf_token = decorator_from_middleware ( _EnsureCsrfToken ) <EOL> requires_csrf_token . __name__ = '<STR_LIT>' <EOL> requires_csrf_token . __doc__ = """<STR_LIT>""" <EOL> def csrf_response_exempt ( view_func ) : <EOL> """<STR_LIT>""" <EOL> def wrapped_view ( * args , ** kwargs ) : <EOL> resp = view_func ( * args , ** kwargs ) <EOL> resp . csrf_exempt = True <EOL> return resp <EOL> return wraps ( view_func , assigned = available_attrs ( view_func ) ) ( wrapped_view ) <EOL> def csrf_view_exempt ( view_func ) : <EOL> """<STR_LIT>""" <EOL> def wrapped_view ( * args , ** kwargs ) : <EOL> return view_func ( * args , ** kwargs ) <EOL> wrapped_view . csrf_exempt = True <EOL> return wraps ( view_func , assigned = available_attrs ( view_func ) ) ( wrapped_view ) <EOL> def csrf_exempt ( view_func ) : <EOL> """<STR_LIT>""" <EOL> return csrf_response_exempt ( csrf_view_exempt ( view_func ) ) </s>
