#NEWLINE# def signature( * args , **kwargs ) : #NEWLINE# #INDENT# sig = wsme . signature ( * args , ** kwargs ) #NEWLINE# def decorate( f ) : #NEWLINE# #INDENT# args = inspect . getargspec ( f ) [ 0 ] #NEWLINE# with_self = ( ( args [ 0 ] == 'self' ) if args else False ) #NEWLINE# f = sig ( f ) #NEWLINE# funcdef = wsme . api . FunctionDefinition . get ( f ) #NEWLINE# funcdef . resolve_types ( wsme . types . registry ) #NEWLINE# @ functools . wraps ( f ) #NEWLINE# def callfunction( * args ) : #NEWLINE# #INDENT# if with_self : #NEWLINE# #INDENT# if ( len ( args ) == 1 ) : #NEWLINE# #INDENT# self = args [ 0 ] #NEWLINE# request = self . request #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( args ) == 2 ) : #NEWLINE# #INDENT# ( self , request ) = args #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'Cannot do anything with these arguments' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# request = args [ 0 ] #NEWLINE# #UNINDENT# request . override_renderer = ( 'wsme' + get_outputformat ( request ) ) #NEWLINE# try : #NEWLINE# #INDENT# ( args , kwargs ) = combine_args ( funcdef , ( args_from_args ( funcdef , ( ) , request . matchdict ) , args_from_params ( funcdef , request . params ) , args_from_body ( funcdef , request . body , request . content_type ) ) ) #NEWLINE# wsme . runtime . check_arguments ( funcdef , args , kwargs ) #NEWLINE# if funcdef . pass_request : #NEWLINE# #INDENT# kwargs [ funcdef . pass_request ] = request #NEWLINE# #UNINDENT# if with_self : #NEWLINE# #INDENT# args . insert ( 0 , self ) #NEWLINE# #UNINDENT# result = f ( * args , ** kwargs ) #NEWLINE# return { #NEWLINE# #INDENT# 'datatype' : funcdef . return_type , #NEWLINE# 'result' : result , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# exception_info = sys . exc_info ( ) #NEWLINE# orig_exception = exception_info [ 1 ] #NEWLINE# orig_code = getattr ( orig_exception , 'code' , None ) #NEWLINE# data = wsme . api . format_exception ( exception_info ) #NEWLINE# if ( orig_code is not None ) : #NEWLINE# #INDENT# data [ 'orig_code' ] = orig_code #NEWLINE# #UNINDENT# return data #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# del exception_info #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# callfunction . wsme_func = f #NEWLINE# return callfunction #NEWLINE# #UNINDENT# return decorate