#NEWLINE# def do_POST( self ) : #NEWLINE# #INDENT# self . instance ( ) #NEWLINE# file_data = None #NEWLINE# listener_widget = None #NEWLINE# listener_function = None #NEWLINE# try : #NEWLINE# #INDENT# filename = self . headers [ 'filename' ] #NEWLINE# listener_widget = runtimeInstances [ self . headers [ 'listener' ] ] #NEWLINE# listener_function = self . headers [ 'listener_function' ] #NEWLINE# form = cgi . FieldStorage ( fp = self . rfile , headers = self . headers , environ = { #NEWLINE# #INDENT# 'REQUEST_METHOD' : 'POST' , #NEWLINE# 'CONTENT_TYPE' : self . headers [ 'Content-Type' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# for field in form . keys ( ) : #NEWLINE# #INDENT# field_item = form [ field ] #NEWLINE# if field_item . filename : #NEWLINE# #INDENT# file_data = field_item . file . read ( ) #NEWLINE# file_len = len ( file_data ) #NEWLINE# self . log . debug ( ( 'post: uploaded %s as "%s" (%d bytes)\n' % ( field , field_item . filename , file_len ) ) ) #NEWLINE# get_method_by_name ( listener_widget , listener_function ) ( listener_widget , filename ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . log . debug ( ( 'post: %s=%s\n' % ( field , form [ field ] . value ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( file_data is not None ) : #NEWLINE# #INDENT# self . log . debug ( ( 'GUI - server.py do_POST: fileupload name= %s' % filename ) ) #NEWLINE# self . send_response ( 200 ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# self . log . error ( 'post: failed' , exc_info = True ) #NEWLINE# self . send_response ( 400 ) #NEWLINE# #UNINDENT# self . send_header ( 'Content-type' , 'text/plain' ) #NEWLINE# self . end_headers ( )