#NEWLINE# @ gen . coroutine #NEWLINE# def _view( self , url , **kwargs ) : #NEWLINE# #INDENT# body = kwargs . get ( 'body' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# options = [ ] #NEWLINE# if kwargs : #NEWLINE# #INDENT# for ( key , value ) in kwargs . items ( ) : #NEWLINE# #INDENT# if ( key == 'body' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( key == 'keys' ) : #NEWLINE# #INDENT# body . update ( { #NEWLINE# #INDENT# 'keys' : value , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# value = url_escape ( ( value if ( key in ( 'startkey_docid' , 'endkey_docid' ) ) else json_encode ( value ) ) ) #NEWLINE# options . append ( '=' . join ( [ key , value ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if options : #NEWLINE# #INDENT# url = '{0}?{1}' . format ( url , '&' . join ( options ) ) #NEWLINE# #UNINDENT# if body : #NEWLINE# #INDENT# r = ( yield self . _http_post ( url , json_encode ( body ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# r = ( yield self . _http_get ( url ) ) #NEWLINE# #UNINDENT# raise gen . Return ( options )