<s> from django . conf import settings <EOL> from django . http import HttpResponseForbidden <EOL> from django . template import Context , Engine , TemplateDoesNotExist , loader <EOL> from django . utils . translation import ugettext as _ <EOL> from django . utils . version import get_docs_version <EOL> CSRF_FAILURE_TEMPLATE = """<STR_LIT>""" <EOL> CSRF_FAILURE_TEMPLATE_NAME = "<STR_LIT>" <EOL> def csrf_failure ( request , reason = "<STR_LIT>" , template_name = CSRF_FAILURE_TEMPLATE_NAME ) : <EOL> """<STR_LIT>""" <EOL> from django . middleware . csrf import REASON_NO_REFERER , REASON_NO_CSRF_COOKIE <EOL> c = Context ( { <EOL> '<STR_LIT:title>' : _ ( "<STR_LIT>" ) , <EOL> '<STR_LIT>' : _ ( "<STR_LIT>" ) , <EOL> '<STR_LIT>' : reason , <EOL> '<STR_LIT>' : reason == REASON_NO_REFERER , <EOL> '<STR_LIT>' : _ ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> '<STR_LIT>' : _ ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> '<STR_LIT>' : reason == REASON_NO_CSRF_COOKIE , <EOL> '<STR_LIT>' : _ ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> '<STR_LIT>' : _ ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> '<STR_LIT>' : settings . DEBUG , <EOL> '<STR_LIT>' : get_docs_version ( ) , <EOL> '<STR_LIT>' : _ ( "<STR_LIT>" ) , <EOL> } ) <EOL> try : <EOL> t = loader . get_template ( template_name ) <EOL> except TemplateDoesNotExist : <EOL> if template_name == CSRF_FAILURE_TEMPLATE_NAME : <EOL> t = Engine ( ) . from_string ( CSRF_FAILURE_TEMPLATE ) <EOL> else : <EOL> raise <EOL> return HttpResponseForbidden ( t . render ( c ) , content_type = '<STR_LIT>' ) </s>
