def POST(self): print 'write_blog函数调用POST' GetDict=web.input() #for i in web.input(): # print type(i),type(web.input()[i]),i,'-->',GetDict[i] try: _id,name_id,date,title,content=GetDict["_id"],GetDict["name_id"],GetDict["date"],GetDict["title"],GetDict["content"] try:classification=GetDict["classification"] except:classification="未分类博客" if name_id and date and title and content: T=Model.Add_OR_Edit_blog_articles(_id,name_id,date,title,content,classification) return response(True,"操作成功!") if T else response(False,"数据库忙") #return web.seeother('/user_blog?name_id='+name_id) else: return response(False,"内容不能为空") except: raise '发博文请求错误'
def GET(self): print 'blog_single_other函数调用GET' data=web.input() visitors=data['visitors'] article_id=data['article_id'] article_author=data['article_author'] if 'comment' in data: comment={} comment['content']=data['comment'] comment['author']=visitors import time comment['date']=time.strftime('%Y-%m-%d',time.localtime(time.time())) Model.Add_OR_Edit_blog_articles(article_id,comment=comment) web.seeother('/blog_single_other?visitors='+visitors+'&&article_author='+article_author+'&&article_id='+article_id) #获取所看文章信息 blog=Model.GetBlogs(_id=article_id) #获取文章作者信息 person_info=Model.login(article_author)[0] classification=Model.GetClassification(article_author) return render.blog_single_other(person_info,classification,blog,visitors)