#NEWLINE# @ timeout #NEWLINE# @ defer . inlineCallbacks #NEWLINE# def update( self , spec , document , upsert = False , multi = False , safe = None , flags = 0 , **kwargs ) : #NEWLINE# #INDENT# if ( not isinstance ( spec , dict ) ) : #NEWLINE# #INDENT# raise TypeError ( 'TxMongo: spec must be an instance of dict.' ) #NEWLINE# #UNINDENT# if ( not isinstance ( document , dict ) ) : #NEWLINE# #INDENT# raise TypeError ( 'TxMongo: document must be an instance of dict.' ) #NEWLINE# #UNINDENT# if ( not isinstance ( upsert , bool ) ) : #NEWLINE# #INDENT# raise TypeError ( 'TxMongo: upsert must be an instance of bool.' ) #NEWLINE# #UNINDENT# if multi : #NEWLINE# #INDENT# flags |= UPDATE_MULTI #NEWLINE# #UNINDENT# if upsert : #NEWLINE# #INDENT# flags |= UPDATE_UPSERT #NEWLINE# #UNINDENT# spec = BSON . encode ( spec ) #NEWLINE# document = BSON . encode ( document ) #NEWLINE# update = Update ( flags = flags , collection = str ( self ) , selector = spec , update = document ) #NEWLINE# proto = ( yield self . _database . connection . getprotocol ( ) ) #NEWLINE# check_deadline ( kwargs . pop ( '_deadline' , None ) ) #NEWLINE# proto . send_UPDATE ( update ) #NEWLINE# write_concern = self . _get_write_concern ( safe , ** kwargs ) #NEWLINE# if write_concern . acknowledged : #NEWLINE# #INDENT# ret = ( yield proto . get_last_error ( str ( self . _database ) , ** write_concern . document ) ) #NEWLINE# defer . returnValue ( ret )