def zan(self, id_reply): ''' 先在外部表中更新,然后更新内部表字段的值。 有冗余,但是查看的时候避免了联合查询 ''' logger.info('zan: {0}'.format(id_reply)) MReply2User.create_reply(self.userinfo.uid, id_reply) cur_count = MReply2User.get_voter_count(id_reply) if cur_count: MReply.update_vote(id_reply, cur_count) output = {'text_zan': cur_count} else: output = {'text_zan': 0} logger.info('zan dic: {0}'.format(cur_count)) return json.dump(output, self)
def test_get_voter_count(self): MReply2User.get_voter_count(self.reply_id) assert True