#NEWLINE# def save_contact( contact ) : #NEWLINE# #INDENT# contact . name = request . form . get ( 'name' ) #NEWLINE# contact . image = request . form . get ( 'image' ) #NEWLINE# contact . url = request . form . get ( 'url' ) #NEWLINE# for nick in contact . nicks : #NEWLINE# #INDENT# db . session . delete ( nick ) #NEWLINE# #UNINDENT# db . session . commit ( ) #NEWLINE# contact . nicks = [ Nick ( name = nick . strip ( ) ) for nick in request . form . get ( 'nicks' , '' ) . split ( ',' ) if nick . strip ( ) ] #NEWLINE# contact . social = util . multiline_string_to_list ( request . form . get ( 'social' ) ) #NEWLINE# if ( not contact . id ) : #NEWLINE# #INDENT# db . session . add ( contact ) #NEWLINE# #UNINDENT# db . session . commit ( ) #NEWLINE# if contact . nicks : #NEWLINE# #INDENT# return redirect ( url_for ( '.contact_by_name' , name = contact . nicks [ 0 ] . name ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return redirect ( url_for ( '.contacts' ) )