#NEWLINE# @ classmethod #NEWLINE# def ToMessageCollection( cls , items , collection_fields = None , next_cursor = None ) : #NEWLINE# #INDENT# 'Converts a list of entities and cursor to ProtoRPC (collection) message.\n\n    Uses the fields list to create a ProtoRPC (collection) message class and\n    then converts each item into a ProtoRPC message to be set as a list of\n    items.\n\n    If the cursor is not null, we convert it to a websafe string and set the\n    nextPageToken field on the result message.\n\n    Args:\n      items: A list of entities of this model.\n      collection_fields: Optional fields, defaults to None. Passed to\n          ProtoCollection to create a ProtoRPC message class for for the\n          collection of messages.\n      next_cursor: An optional query cursor, defaults to None.\n\n    Returns:\n      The ProtoRPC message created using the entities and cursor provided,\n          making sure that the entity message class matches collection_fields.\n    ' #NEWLINE# proto_model = cls . ProtoCollection ( collection_fields = collection_fields ) #NEWLINE# items_as_message = [ item . ToMessage ( fields = collection_fields ) for item in items ] #NEWLINE# result = proto_model ( items = items_as_message ) #NEWLINE# if ( next_cursor is not None ) : #NEWLINE# #INDENT# result . nextPageToken = next_cursor . to_websafe_string ( ) #NEWLINE# #UNINDENT# return result