Example #1
0
 def delete(self, id):
     try:
         story = Story.objects(id=id).first()
         story.delete()
     except Exception, e:
         logging.error(e)
         self.write({'errcode': 1, 'errmsg': 'del failed'})
Example #2
0
    def put(self, id):
        try:
            story = Story.objects(id=id).first()

            story.title = self.get_argument('title')
            story.content = self.get_argument('content')
            story.tags = self.get_arguments('tags')

            story.update()

            self.write({'errcode': 0, 'errmsg': 'success', 'data': story.to_json()})
        except Exception, e:
            logging.error(e)
            self.write({'errcode': 1, 'errmsg': 'put failed'})