#NEWLINE# def __call__( self , request , methodname ) : #NEWLINE# #INDENT# handler = self . _fmap . get ( methodname ) #NEWLINE# if ( kwargs is None ) : #NEWLINE# #INDENT# return JSONNotFound ( ( 'No method ' + methodname ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# data = request . POST . get ( 'data' ) #NEWLINE# if data : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# arguments = self . _decoder . decode ( data ) #NEWLINE# if ( ( len ( arguments ) == 2 ) and isinstance ( arguments [ 1 ] , dict ) ) : #NEWLINE# #INDENT# args = ( ) #NEWLINE# kwargs = arguments [ 1 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# args = tuple ( arguments [ 1 : ] ) #NEWLINE# kwargs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# ( ex , val , tb ) = sys . exc_info ( ) #NEWLINE# tblist = traceback . extract_tb ( tb ) #NEWLINE# request . log_error ( ( 'JSONDispatcher args: %s (%s)\n' % ( ex , val ) ) ) #NEWLINE# return JSONServerError ( ex , val , tblist ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# args = ( ) #NEWLINE# kwargs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# with GlobalRequest ( request ) : #NEWLINE# #INDENT# rv = handler ( * args , ** kwargs ) #NEWLINE# #UNINDENT# json = self . _encoder . encode ( rv ) #NEWLINE# return HttpResponse ( json , 'application/json' ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# ( ex , val , tb ) = sys . exc_info ( ) #NEWLINE# tblist = traceback . extract_tb ( tb ) #NEWLINE# del tb #NEWLINE# request . log_error ( ( 'JSONDispatcher: %s (%s)\n' % ( ex , val ) ) ) #NEWLINE# return JSONServerError ( ex , val , tblist )