#NEWLINE# @ administrator #NEWLINE# def post( self ) : #NEWLINE# #INDENT# key = self . get_argument ( 'key' , None ) #NEWLINE# if key : #NEWLINE# #INDENT# entry = Entry . get ( key ) #NEWLINE# entry . title = self . get_argument ( 'title' ) #NEWLINE# entry . body_source = self . get_argument ( 'body_source' ) #NEWLINE# entry . html = tornado . escape . linkify ( self . get_argument ( 'body_source' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# title = self . get_argument ( 'title' ) #NEWLINE# slug = unicodedata . normalize ( 'NFKD' , title ) . encode ( 'ascii' , 'ignore' ) #NEWLINE# slug = re . sub ( '[^\\w]+' , ' ' , slug ) #NEWLINE# slug = '-' . join ( slug . lower ( ) . strip ( ) . split ( ) ) #NEWLINE# if ( not slug ) : #NEWLINE# #INDENT# slug = 'entry' #NEWLINE# #UNINDENT# while True : #NEWLINE# #INDENT# existing = db . Query ( Entry ) . filter ( 'slug =' , slug ) . get ( ) #NEWLINE# if ( ( not existing ) or ( str ( existing . key ( ) ) == key ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# slug += '-2' #NEWLINE# #UNINDENT# entry = Entry ( author = self . current_user , title = title , slug = slug , body_source = self . get_argument ( 'body_source' ) , html = tornado . escape . linkify ( self . get_argument ( 'body_source' ) ) ) #NEWLINE# #UNINDENT# entry . put ( ) #NEWLINE# self . redirect ( ( '/entry/' + entry . slug ) )