示例#1
0
 def group_save(self, group):
     gid = group.gid
     try:
         if not gid:
             db.session.add(group)
         else:
             t_dict = mymodel.model_todbdict(group)
             t_dict.pop('gid')
             t_dict.pop('create_time')
             db.session.query(Group).filter(Group.gid == gid).update(t_dict)
         db.session.commit()
         return True
     except Exception as e:
         logger.exception(e)
         db.session.rollback()
         return False
示例#2
0
 def album_save(self, album):
     aid = album.aid
     try:
         if not aid:
             db.session.add(album)
         else:
             t_dict = mymodel.model_todbdict(album)
             t_dict.pop('aid')
             t_dict.pop('create_time')
             db.session.query(Album).filter(Album.aid == aid).update(t_dict)
         db.session.commit()
         return True
     except Exception as e:
         logger.exception(e)
         db.session.rollback()
         return False
示例#3
0
 def photo_save(self, photo):
     pid = photo.pid
     try:
         if not pid:
             db.session.add(photo)
         else:
             t_dict = mymodel.model_todbdict(photo)
             t_dict.pop('pid')
             t_dict.pop('fid')
             t_dict.pop('album_id')
             db.session.query(Photo).filter(Photo.pid == pid).update(t_dict)
         db.session.commit()
         return True
     except Exception as e:
         logger.exception(e)
         db.session.rollback()
         return False
示例#4
0
 def paper_save(self, paper):
     paper_id = paper.paper_id
     try:
         if not paper_id:
             db.session.add(paper)
             db.session.flush()
             paper_id = paper.paper_id
         else:
             t_dict = mymodel.model_todbdict(paper)
             t_dict.pop('paper_id')
             t_dict.pop('create_time')
             db.session.query(Paper).filter(
                 Paper.paper_id == paper_id).update(t_dict)
         db.session.commit()
         return self.get_paper(paper_id)
     except Exception as e:
         logger.exception(e)
         return False
示例#5
0
 def book_save(self, book):
     book_id = book.book_id
     try:
         if not book_id:
             db.session.add(book)
         else:
             book.update_time = mytime.get_now_datetime()
             t_dict = mymodel.model_todbdict(book)
             t_dict.pop('book_id')
             t_dict.pop('create_time')
             db.session.query(Book).filter(
                 Book.book_id == book_id).update(t_dict)
         db.session.commit()
         return True
     except Exception as e:
         logger.exception(e)
         db.session.rollback()
         return False