本文整理汇总了Python中myapp.ApiObject.ApiObject.get_cached_object方法的典型用法代码示例。如果您正苦于以下问题:Python ApiObject.get_cached_object方法的具体用法?Python ApiObject.get_cached_object怎么用?Python ApiObject.get_cached_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myapp.ApiObject.ApiObject
的用法示例。
在下文中一共展示了ApiObject.get_cached_object方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mapping
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import get_cached_object [as 别名]
def mapping(bbs,thread_key):
#直値
if(len(thread_key)>20):
return ApiObject.get_cached_object(thread_key)
#キャッシュヒット判定
bbs_key=str(bbs.key())
mapped_key=memcache.get(BbsConst.OBJECT_THREAD_ID_MAPPING_HEADER+"_"+bbs_key+"_"+thread_key)
if mapped_key is not None:
return ApiObject.get_cached_object(mapped_key)
#探索
query=db.Query(MesThread,keys_only=True)
query.filter("bbs_key =",bbs)
query.filter("short =",thread_key)
thread=None
try:
thread=query[0]
thread=ApiObject.get_cached_object(thread)
except:
thread=None
#キャッシュに登録
if thread and thread.short:
new_key=str(thread.key())
memcache.set(BbsConst.OBJECT_THREAD_ID_MAPPING_HEADER+"_"+bbs_key+"_"+thread.short,new_key,BbsConst.OBJECT_MAPPING_CACHE_TIME)
#image_keyを取得しておく
if thread and thread.image_key:
thread.cached_image_key=str(thread.image_key.key())
#スレッドを返す
return thread
示例2: get_thread_list
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import get_cached_object [as 别名]
def get_thread_list(self,analytics):
start_date=str(datetime.date.today()+datetime.timedelta(days=-1))
end_date=str(datetime.date.today())
result=analytics.get("page",".*",start_date,end_date)
thread_list=[]
for one in result:
url=one["ga:pagePath"]
count=int(one["ga:pageviews"])
data=url.split("/")
try:
bbs_name=str(data[1])
thread_name=str(data[2].split(".")[0])
except:
continue
bbs_key=MappingId.mapping(bbs_name)
bbs=ApiObject.get_cached_object(bbs_key)
if(not bbs):
continue
thread = MappingThreadId.mapping(bbs,thread_name)
if(not thread):
continue
while(count>=1):
thread_list.append(thread.key())
count=count-1
return thread_list
示例3: get_bbs
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import get_cached_object [as 别名]
def get_bbs(req,bbs_key):
bbs_key=MappingId.mapping(bbs_key)
if(bbs_key==""):
Alert.alert_msg_notfound(req)
return None
bbs=ApiObject.get_cached_object(bbs_key)
if(bbs == None):
Alert.alert_msg_notfound(req)
return None
return bbs
示例4: post
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import get_cached_object [as 别名]
def post(self):
#BBS取得
bbs_key=self.request.get("bbs")
bbs=None
if(bbs_key):
bbs=ApiObject.get_cached_object(str(bbs_key))
if(not bbs):
return
#カウンタを更新
counter=bbs.counter
counter.update_counter()
示例5: bookmark_get_thread_user_list
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import get_cached_object [as 别名]
def bookmark_get_thread_user_list(req):
thread_key=req.request.get("thread_key")
bookmark_list=Bookmark.all().filter("thread_key_list =",db.Key(thread_key)).fetch(limit=100)
#comment
comment={}
thread=ApiObject.get_cached_object(db.Key(thread_key))
if(not thread):
return []
if(thread.bookmark_comment):
comment=pickle.loads(thread.bookmark_comment)
#user list
dic=[]
for bookmark in bookmark_list:
one_dic=ApiObject.create_user_object(req,bookmark)
user_id=None
if(one_dic.has_key("user_id")):
user_id=one_dic["user_id"]
if(user_id and comment.has_key(user_id)):
one_dic["comment"]=comment[user_id]
dic.append(one_dic)
return dic
示例6: get
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import get_cached_object [as 别名]
def get(self,bbs_key,thread_key):
SetUtf8.set()
#ホストチェック
if SpamCheck.is_deny(self.request):
self.response.set_status(401)
return
#英語版かどうか
is_english=CssDesign.is_english(self)
#BBSを取得
bbs_key=MappingId.mapping(bbs_key)
bbs=ApiObject.get_cached_object(bbs_key)
if(bbs == None):
Alert.alert_msg_notfound(self)
return
#BBSが削除されていた場合
if(bbs.del_flag) :
if(is_english):
Alert.alert_msg_with_write(self,"This bbs was deleted.")
else:
Alert.alert_msg_with_write(self,"このBBSは削除されました。")
return
#ページ番号を取得
col_num = 10
page = 1
if self.request.get("page"):
page = int(self.request.get("page"))
if page < 1:
page=1
#メンテナンス画面
is_maintenance=0
if(MaintenanceCheck.is_appengine_maintenance()):
is_maintenance=1
#オーダー取得
order="update"
if(bbs.default_comment_order==1):
order="new"
if self.request.get("order"):
order=self.request.get("order")
#スレッド取得
thread=ShowThread.get_thread(bbs,thread_key)
if(thread == None):
Alert.alert_msg_notfound(self)
return
#コメント数を更新
if(bbs.page_comment_n):
col_num=bbs.page_comment_n
if(self.request.get("limit")):
col_num=int(self.request.get("limit"))
#コメントの一覧を取得
query=ShowThread.get_comment_query(thread,order)
entry_num = query.count()
if(entry_num==0):
com_list_ = []
else:
com_list_ = query.fetch(limit=col_num, offset=(page-1)*col_num)
#検索
search=""
if(self.request.get("search")):
search=self.request.get("search")
query=""+search+' thread_key:"'+str(thread.key())+'"'
com_list_=SearchThread.search(query,page,col_num,BbsConst.SEARCH_ENTRY_INDEX_NAME)
#実体への変換
com_list_=ApiObject.get_cached_object_list(com_list_)
#現在のスレッドへのURLを取得
host_url=MappingId.mapping_host_with_scheme(self.request)+"/"
#編集モードか
user = users.get_current_user()
edit_flag = 0
if(not OwnerCheck.check(bbs,user)):
edit_flag = 1
logined=0
if(user):
logined=1
owner=user
if(OwnerCheck.check(bbs,user)):
owner=None
admin_user=OwnerCheck.is_admin(user)
#ページリンクを作成
page_url_base = MappingId.get_usr_url(host_url,bbs)+thread_key+'.html?page='
page_list=ShowThread.create_page_list(page,entry_num,col_num)
#掲示板のデザインを取得
#.........这里部分代码省略.........
示例7: _create_ranking_core
# 需要导入模块: from myapp.ApiObject import ApiObject [as 别名]
# 或者: from myapp.ApiObject.ApiObject import get_cached_object [as 别名]
def _create_ranking_core(self,thread_list):
#ハッシュにthread_keyを入れていく
rank={}
first_ranking_list=[]
for thread in thread_list:
if(rank.has_key(thread)):
rank[thread]=rank[thread]+1
else:
rank[thread]=1
first_ranking_list.append(thread)
#1次ランキングに出現したもののスコア補正
rank_bbs={}
rank_user={}
for k in first_ranking_list:
#スレッドの実体を取得
thread=ApiObject.get_cached_object(k)
#イラストモードだけ
if(not thread or thread.illust_mode!=BbsConst.ILLUSTMODE_ILLUST):
rank[k]=0
continue
#BBSランクを加算(純粋PV)
if(thread):
bbs=thread.cached_bbs_key
bbs_main=ApiObject.get_cached_object(bbs)
if(not(bbs_main and bbs_main.disable_news)):
if(not rank_bbs.has_key(bbs)):
rank_bbs[bbs]=0
rank_bbs[bbs]=rank_bbs[bbs]+rank[k]
#USERランクを加算(純粋PV)
if(thread):
user_id=thread.user_id
if(user_id):
if(not rank_user.has_key(user_id)):
rank_user[user_id]=0
rank_user[user_id]=rank_user[user_id]+rank[k]
#経過日数と付加情報で補正
day_left=(self.get_sec(datetime.datetime.now())-self.get_sec(thread.create_date))*1.0/60/60/24
score=0
if(thread.bookmark_count):
score=score+thread.bookmark_count*5
if(thread.applause):
score=score+thread.applause
rank[k]=(rank[k]+score)/(day_left+1)
#非表示スレッドのランクを落とす
if(thread and bbs_main and bbs_main.disable_news):
rank[k]=0
#スレッドランキング作成
self.ranking_list=[]
for k, v in sorted(rank.items(), key=lambda x:x[1], reverse=True):
self.ranking_list.append(k)
if(len(self.ranking_list)>=BbsConst.THREAD_RANKING_MAX):
break
#BBSランキング作成
self.bbs_ranking_list=[]
for k, v in sorted(rank_bbs.items(), key=lambda x:x[1], reverse=True):
self.bbs_ranking_list.append(k)
if(len(self.bbs_ranking_list)>=BbsConst.BBS_RANKING_MAX):
break
#USERランキング作成
self.user_id_ranking_list=[]
for k, v in sorted(rank_user.items(), key=lambda x:x[1], reverse=True):
self.user_id_ranking_list.append(k)
if(len(self.user_id_ranking_list)>=BbsConst.USER_RANKING_MAX):
break