def post(self): pid = int(self.get_argument("id")) post = Post.get(id=pid) post.title = self.get_argument('title') post.content = self.get_argument("content") tags = model.get_tags(str(self.get_argument('tags'))) try: model.tag_save(tags, post.id) post.save() self.success('文章更新成功') except DatabaseError: self.error('文章更新失败')
def post(self): title = self.get_argument('title') content = self.get_argument("content") author_id = self.get_secure_cookie('uid') tags = model.get_tags(str(self.get_argument('tags'))) try: post = Post.create(title=title, content=content, user=author_id, pub_date=datetime.now()) model.tag_save(tags, post.id) except DatabaseError: self.write("<script>alert('文章添加失败');</script>") else: self.redirect('/post/edit/' + str(post.id))