def post(self): tag_id = int(self.get_argument('id')) if not tag_id: tag = Tag() tag.father_id = self.get_argument('father_id') else: tag = self.orm_session.query(Tag).filter_by(id=tag_id).first() if tag: tag.active = self.get_argument('active') tag.name = self.get_argument('name') self.orm_session.add(tag) self.orm_session.commit() self.write(dict(ret=0))