def get(self, cid, n=1): cid = int(cid) qs = Reply.where('cid = %s', cid) total = qs.count() page, limit, offset = page_limit_offset( '/reply_list/%s-%%s'%cid, total, n, PAGE_LIMIT, ) li = qs.order_by('id desc')[offset: offset + limit] txt_bind(li) #print cid == CID_USER if cid == CID_USER: Wall.mc_bind(li, 'wall', 'rid') wall_list = [i.wall for i in li] Zsite.mc_bind(wall_list, 'from_user', 'from_id') Zsite.mc_bind(wall_list, 'to_user', 'to_id') else: Po.mc_bind(li, 'po', 'rid') Zsite.mc_bind(li, 'user', 'user_id') self.render( reply_list=li, page=page, )
def po_json(user_id, po_id_list, line_width): po_id_list = map(int,po_id_list) po_list = Po.mc_get_list(po_id_list) txt_bind(po_list) Zsite.mc_bind(po_list, 'user', 'user_id') result = [] fav_dict = fav_cid_dict( user_id, po_id_list ) for po in po_list: name = po.name user = po.user name_len = cnenlen(name) txt = po.txt if txt and name_len < line_width: tip = cnenoverflow(txt, line_width-name_len)[0] else: tip = '' id = po.id if not user: user_id = 0 user_name = None else: user_id = user.id user_name = None result.append(( id, name, tip, # user_id, # user_name, fav_dict[id] )) # 0 1 2 3 4 5 # id , name, tip, author_id , author_name , is_star return result
def po_json(user_id, po_id_list, line_width): po_id_list = map(int, po_id_list) po_list = Po.mc_get_list(po_id_list) txt_bind(po_list) Zsite.mc_bind(po_list, 'user', 'user_id') result = [] fav_dict = fav_cid_dict(user_id, po_id_list) for po in po_list: name = po.name user = po.user name_len = cnenlen(name) txt = po.txt if txt and name_len < line_width: tip = cnenoverflow(txt, line_width - name_len)[0] else: tip = '' id = po.id if not user: user_id = 0 user_name = None else: user_id = user.id user_name = None result.append(( id, name, tip, # user_id, # user_name, fav_dict[id])) # 0 1 2 3 4 5 # id , name, tip, author_id , author_name , is_star return result