#NEWLINE# def extract_token_from_cookie( request ) : #NEWLINE# #INDENT# 'Given a Request object, return a csrf_token.\n    ' #NEWLINE# try : #NEWLINE# #INDENT# token = request . headers . cookie [ 'csrf_token' ] . value #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# token = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# token = _sanitize_token ( token ) #NEWLINE# #UNINDENT# if ( request . path . raw . startswith ( '/assets/' ) or request . path . raw . startswith ( '/callbacks/' ) ) : #NEWLINE# #INDENT# token = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# token = ( token or _get_new_token ( ) ) #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'csrf_token' : request , #NEWLINE# #UNINDENT# }