#NEWLINE# def _create_or_update_user( self , create , name , password , read_only , **kwargs ) : #NEWLINE# #INDENT# 'Use a command to create (if create=True) or modify a user.\n        ' #NEWLINE# opts = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( read_only or ( create and ( 'roles' not in kwargs ) ) ) : #NEWLINE# #INDENT# warnings . warn ( 'Creating a user with the read_only option or without roles is deprecated in MongoDB >= 2.6' , DeprecationWarning ) #NEWLINE# opts [ 'roles' ] = [ self . _default_role ( read_only ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if read_only : #NEWLINE# #INDENT# warnings . warn ( "The read_only option is deprecated in MongoDB >= 2.6, use 'roles' instead" , DeprecationWarning ) #NEWLINE# #UNINDENT# #UNINDENT# if ( password is not None ) : #NEWLINE# #INDENT# if ( 'digestPassword' in kwargs ) : #NEWLINE# #INDENT# raise ConfigurationError ( "The digestPassword option is not supported via add_user. Please use db.command('createUser', ...) instead for this option." ) #NEWLINE# #UNINDENT# opts [ 'pwd' ] = auth . _password_digest ( name , command_name ) #NEWLINE# opts [ 'digestPassword' ] = False #NEWLINE# #UNINDENT# if ( self . write_concern . acknowledged and self . write_concern . document ) : #NEWLINE# #INDENT# opts [ 'writeConcern' ] = self . write_concern . document #NEWLINE# #UNINDENT# opts . update ( kwargs ) #NEWLINE# if create : #NEWLINE# #INDENT# command_name = 'createUser' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# command_name = 'updateUser' #NEWLINE# #UNINDENT# self . command ( command_name , name , ** opts )