Esempio n. 1
0
	def get(self):
		is_iphone=CssDesign.is_iphone(self)

		page=1
		page_unit=20
		if(self.request.get("page")):
			page=int(self.request.get("page"))
		
		rank=Ranking.get_or_insert(BbsConst.THREAD_RANKING_KEY_NAME)
		ranking_mode=self.request.get("mode")
		
		ranking_id_list=rank.user_id_ranking_list[(page-1)*page_unit:page*page_unit]
		ranking_list=[]
		for user_id in ranking_id_list:
			obj=ApiObject.get_bookmark_of_user_id(user_id)
			if(obj):
				if(obj.disable_rankwatch):
					ranking_list.append(None)
					continue
				obj=ApiObject.create_user_object(self,obj)
				ranking_list.append(obj)

		user = users.get_current_user()
		user_rank=0
		if(user):
			rank=Ranking.get_by_key_name(BbsConst.THREAD_RANKING_KEY_NAME)
			if(rank):
				user_rank=rank.get_user_rank(user.user_id())

		template_values = {
			'host': "./",
			'is_iphone': is_iphone,
			'user': user,
			'user_rank': user_rank,
			'redirect_url': self.request.path,
			'mode': "ranking",
			'header_enable': False,
			'ranking_list': ranking_list,
			'ranking_mode': ranking_mode,
			'page': page,
			'page_unit': page_unit
		}

		path = '/html/portal.html'
		self.response.out.write(template_select.render(path, template_values))
Esempio n. 2
0
	def feed_get_thread_list(req,order,offset,limit):
		#最大取得数
		if(limit>100):
			limit=100

		#キャッシュが有効かどうか
		cache_enable=ApiFeed._is_cache_enable(offset,limit,order)

		#キャッシュ取得
		cache_id=ApiFeed._get_cache_id(order,req.request.get("bbs_id"),offset,limit)
		if(cache_enable):
			data=memcache.get(cache_id)
			if(data):
				dic=ApiObject.create_thread_object_list(req,data,req.request.get("bbs_id"))
				return dic
		
		#スレッド一覧取得
		if(order=="hot"):
			rank=Ranking.get_by_key_name(BbsConst.THREAD_RANKING_KEY_NAME)
			if(rank==None):
				rank=Ranking.get_or_insert(BbsConst.THREAD_RANKING_KEY_NAME)
			thread_list=rank.get_rank(offset,limit)
			bbs_id=None
		else:
			query=ApiFeed._get_query(order,req.request.get("event_id"))

			bbs_id=None
			if(req.request.get("bbs_id")):
				bbs_key=MappingId.mapping(req.request.get("bbs_id"))
				if(bbs_key==""):
					return None #bbs not found
				query.filter("bbs_key =",db.get(bbs_key))
				bbs_id=True

			thread_list=query.fetch(offset=offset,limit=limit)
		
		#キャッシュに乗せる
		if(cache_enable):
			memcache.set(cache_id,thread_list,BbsConst.TOPPAGE_FEED_CACHE_TIME)

		#リスト作成
		dic=ApiObject.create_thread_object_list(req,thread_list,bbs_id)

		return dic
Esempio n. 3
0
	def feed_get_bbs_list(req,order,offset,limit):
		#最大取得数
		if(limit>100):
			limit=100

		#キャッシュが有効かどうか
		cache_enable=0
		if(offset==0):
			cache_enable=1
		
		#キャッシュ取得
		cache_id=BbsConst.OBJECT_CACHE_HEADER+BbsConst.OBJECT_BBS_RANKING_HEADER
		if(cache_enable):
			data=memcache.get(cache_id)
		else:
			data=None
		if(data and cache_enable):
			dic=[]
			for bbs in data:
				dic.append(ApiObject.create_bbs_object(req,bbs))
			return dic
		
		#BBS一覧取得
		rank=Ranking.get_by_key_name(BbsConst.THREAD_RANKING_KEY_NAME)
		if(rank==None):
			rank=Ranking.get_or_insert(BbsConst.THREAD_RANKING_KEY_NAME)
		bbs_list=rank.get_bbs_rank(offset,limit)
		
		#リスト作成
		bbs_list=ApiObject.get_cached_object_list(bbs_list)

		#キャッシュに乗せる
		if(cache_enable):
			memcache.set(cache_id,bbs_list,BbsConst.TOPPAGE_FEED_CACHE_TIME)

		#オブジェクト作成
		dic=[]
		for bbs in bbs_list:
			dic.append(ApiObject.create_bbs_object(req,bbs))
		
		return dic