#NEWLINE# def runSearchRequest( self , requestStr , requestClass , responseClass , objectGenerator ) : #NEWLINE# #INDENT# '\n        Runs the specified request. The request is a string containing\n        a JSON representation of an instance of the specified requestClass.\n        We return a string representation of an instance of the specified\n        responseClass in JSON format. Objects are filled into the page list\n        using the specified object generator, which must return\n        (object, nextPageToken) pairs, and be able to resume iteration from\n        any point using the nextPageToken attribute of the request object.\n        ' #NEWLINE# self . startProfile ( ) #NEWLINE# try : #NEWLINE# #INDENT# requestDict = json . loads ( requestStr ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# raise exceptions . InvalidJsonException ( requestStr ) #NEWLINE# #UNINDENT# self . validateRequest ( requestDict , requestClass ) #NEWLINE# request = requestClass . fromJsonDict ( responseString ) #NEWLINE# if ( request . pageSize is None ) : #NEWLINE# #INDENT# request . pageSize = self . _defaultPageSize #NEWLINE# #UNINDENT# if ( request . pageSize <= 0 ) : #NEWLINE# #INDENT# raise exceptions . BadPageSizeException ( request . pageSize ) #NEWLINE# #UNINDENT# responseBuilder = protocol . SearchResponseBuilder ( responseClass , request . pageSize , self . _maxResponseLength ) #NEWLINE# nextPageToken = None #NEWLINE# for ( obj , nextPageToken ) in objectGenerator ( request ) : #NEWLINE# #INDENT# responseBuilder . addValue ( obj ) #NEWLINE# if responseBuilder . isFull ( ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# responseBuilder . setNextPageToken ( nextPageToken ) #NEWLINE# responseString = responseBuilder . getJsonString ( ) #NEWLINE# self . validateResponse ( responseString , responseClass ) #NEWLINE# self . endProfile ( ) #NEWLINE# return responseString