#NEWLINE# def create_user_db( auth_id , name , username , email = '' , verified = False , **props ) : #NEWLINE# #INDENT# email = ( email . lower ( ) if email else '' ) #NEWLINE# if ( verified and email ) : #NEWLINE# #INDENT# ( user_dbs , cursors ) = model . User . get_dbs ( email = email , verified = True , limit = 2 ) #NEWLINE# if ( len ( user_dbs ) == 1 ) : #NEWLINE# #INDENT# user_db = user_dbs [ 0 ] #NEWLINE# user_db . auth_ids . append ( auth_id ) #NEWLINE# user_db . put ( ) #NEWLINE# task . new_user_notification ( user_db ) #NEWLINE# return user_db #NEWLINE# #UNINDENT# #UNINDENT# if isinstance ( username , str ) : #NEWLINE# #INDENT# username = username . decode ( 'utf-8' ) #NEWLINE# #UNINDENT# username = unidecode . unidecode ( username . split ( '@' ) [ 0 ] . lower ( ) ) . strip ( ) #NEWLINE# username = re . sub ( '[\\W_]+' , '.' , username ) #NEWLINE# new_username = username #NEWLINE# n = 1 #NEWLINE# while ( not model . User . is_username_available ( user_db ) ) : #NEWLINE# #INDENT# new_username = ( '%s%d' % ( username , n ) ) #NEWLINE# n += 1 #NEWLINE# #UNINDENT# user_db = model . User ( name = name , email = email , username = new_username , auth_ids = ( [ auth_id ] if auth_id else [ ] ) , verified = verified , token = util . uuid ( ) , ** props ) #NEWLINE# user_db . put ( ) #NEWLINE# task . new_user_notification ( user_db ) #NEWLINE# return user_db