#NEWLINE# def Flush( self ) : #NEWLINE# #INDENT# 'Writes the changes in this object to the datastore.' #NEWLINE# session_ids = ( set ( self . to_write ) | set ( self . to_delete ) ) #NEWLINE# mutation_pool = self . data_store . GetMutationPool ( token = self . token ) #NEWLINE# with mutation_pool : #NEWLINE# #INDENT# for session_id in session_ids : #NEWLINE# #INDENT# mutation_pool . MultiSet ( session_id , self . to_write . get ( session_id , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) , to_delete = self . to_delete . get ( session_id , [ ] ) ) #NEWLINE# #UNINDENT# for ( client_id , messages ) in self . client_messages_to_delete . iteritems ( ) : #NEWLINE# #INDENT# self . Delete ( client_id . Queue ( ) , messages , mutation_pool = mutation_pool ) #NEWLINE# #UNINDENT# if self . new_client_messages : #NEWLINE# #INDENT# for ( timestamp , messages ) in utils . GroupBy ( self . new_client_messages , ( lambda x : x [ 1 ] ) ) . iteritems ( ) : #NEWLINE# #INDENT# self . Schedule ( [ x [ 0 ] for x in messages ] , timestamp = timestamp , mutation_pool = mutation_pool ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if self . notifications : #NEWLINE# #INDENT# for ( notification , timestamp ) in self . notifications . itervalues ( ) : #NEWLINE# #INDENT# self . NotifyQueue ( notification , timestamp = timestamp , mutation_pool = mutation_pool ) #NEWLINE# #UNINDENT# mutation_pool . Flush ( ) #NEWLINE# #UNINDENT# self . to_write = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . to_delete = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . client_messages_to_delete = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . notifications = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . new_client_messages = [ ]