def post(self):#搜索动态 a_topic_title = self.get_argument('topic_title') a = a_topic_title if a_topic_title: try: topics = self.db.execute("select * from Topics where topic_title like \'%%%s%%\';" % a_topic_title).fetchall() if topics: retjson = {'code':200,'content':'ok'} content1 = [] for n in topics: content = {} content['uid'] = n.uid user = self.db.query(UsersCache).filter(UsersCache.uid == n.uid).one() content['name'] = user.name content['topics_id'] = n.topic_id content['topic_title'] = n.topic_title content['topic_content'] = n.topic_content content['topic_pic'] = n.topic_pic content['pic_shape'] = n.pic_shape content['topic_starers'] = getLike(n.topic_id,self.Mongodb()) content1.append(content) retjson['content'] = content1 # print retjson else: retjson = {'code':400,'content':'not match topics_title'} except Exception,e: retjson = {'code':400,'content':'failed to search state'}
def post(self): try: times = self.get_argument("times")#刷新次数[0,1,2,。。。。] start = int(times)*12 end = start + 12 try: topics = self.db.query(TopicsCache).order_by((TopicsCache.topic_time+0).desc())[start:end]#topic_time参数格式未解决 if topics: retjson = {'code':200,'content':'success to query state'} content1 = [] for n in topics: content = {} content['uid'] = n.uid try: user = self.db.query(UsersCache).filter(UsersCache.uid==n.uid).one() except NoResultFound: break content['name'] = user.name content['topics_id'] = n.topic_id content['topic_time'] = n.topic_time content['topic_content'] = n.topic_content content['topic_pic'] = n.topic_pic content['pic_shape'] = n.pic_shape content['topic_title'] = n.topic_title content['topic_starers'] = getLike(n.topic_id,self.Mongodb()) content1.append(content) retjson['content'] = content1 else: retjson = {'code':400,'content':'have no state'} except Exception,e: retjson = {'code':400,'content':'failed to query state'} self.render('discover_state.html',content=retjson)
def post(self): #搜索动态 a_topic_title = self.get_argument('topic_title') a = a_topic_title if a_topic_title: try: topics = self.db.execute( "select * from Topics where topic_title like \'%%%s%%\';" % a_topic_title).fetchall() if topics: retjson = {'code': 200, 'content': 'ok'} content1 = [] for n in topics: content = {} content['uid'] = n.uid user = self.db.query(UsersCache).filter( UsersCache.uid == n.uid).one() content['name'] = user.name content['topics_id'] = n.topic_id content['topic_title'] = n.topic_title content['topic_content'] = n.topic_content content['topic_pic'] = n.topic_pic content['pic_shape'] = n.pic_shape content['topic_starers'] = getLike( n.topic_id, self.Mongodb()) content1.append(content) retjson['content'] = content1 # print retjson else: retjson = { 'code': 400, 'content': 'not match topics_title' } except Exception, e: retjson = {'code': 400, 'content': 'failed to search state'}
def get(self): topic_id = self.get_argument('topic_id') retjson = getLike(topic_id,self.Mongodb()) self.write(json.dumps(retjson,ensure_ascii=False,indent=2))