#NEWLINE# def generic_input( request , form , process_upload ) : #NEWLINE# #INDENT# flash = '' #NEWLINE# if form . accepts ( request , session ) : #NEWLINE# #INDENT# ss_fname = ( form . vars . name + '.csv' ) #NEWLINE# ss_fpath = os . path . join ( uploads . spreadsheet_dir ( request ) , ss_fname ) #NEWLINE# pt_fname = ( form . vars . name + '.txt' ) #NEWLINE# pt_fpath = os . path . join ( uploads . plaintext_dir ( request ) , pt_fname ) #NEWLINE# if ( ( not os . path . isfile ( ss_fpath ) ) and ( not os . path . isfile ( pt_fpath ) ) ) : #NEWLINE# #INDENT# ( ssheet , ptext ) = process_upload ( form ) #NEWLINE# uploads . save_spreadsheet ( request , form . vars . name , ssheet ) #NEWLINE# uploads . save_plaintext ( request , form . vars . name , ptext ) #NEWLINE# flash = 'Submission successful.' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# flash = 'Corpus name in use. Please choose another' #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if form . errors : #NEWLINE# #INDENT# flash = 'There were errors in your submission.' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# flash = 'Please fill out the form' #NEWLINE# #UNINDENT# #UNINDENT# return { #NEWLINE# #INDENT# 'form' : form , #NEWLINE# 'flash' : flash , #NEWLINE# #UNINDENT# }