#NEWLINE# def _validate_key( download_key ) : #NEWLINE# #INDENT# '\n    Helper function to make sure the key is valid and all the other constraints on\n    the download are still valid.\n    Returns a tuple (False,"Error Message", None) or (True, None, dl_product)\n    ' #NEWLINE# download_key = download_key . lower ( ) #NEWLINE# if ( not SHA1_RE . search ( download_key ) ) : #NEWLINE# #INDENT# error_message = _ ( 'The download key is invalid.' ) #NEWLINE# return ( False , error_message , None ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# dl_product = DownloadLink . objects . get ( key = download_key ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# error_message = _ ( 'The download key is invalid.' ) #NEWLINE# return ( False , error_message , None ) #NEWLINE# #UNINDENT# ( valid , msg ) = dl_product . is_valid ( ) #NEWLINE# if ( not valid ) : #NEWLINE# #INDENT# return ( False , error_message , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( True , None , dl_product )