本文整理汇总了Python中myapp.MappingId.MappingId类的典型用法代码示例。如果您正苦于以下问题:Python MappingId类的具体用法?Python MappingId怎么用?Python MappingId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MappingId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get
def get(self):
try:
thread = db.get(self.request.get("thread_key"))
bbs = db.get(self.request.get("bbs_key"))
except:
thread = None
bbs = None
if thread == None or bbs == None:
Alert.alert_msg_with_write(self, "拍手対象のスレッドが見つかりません。")
return
not_spam = (
self.request.remote_addr != thread.applause_ip
and self.request.remote_addr != thread.applause_ip2
and self.request.remote_addr != thread.applause_ip3
and self.request.remote_addr != thread.applause_ip4
)
if not_spam or self.request.get("comment"):
if thread.applause:
thread.applause = thread.applause + 1
else:
thread.applause = 1
thread.applause_ip4 = thread.applause_ip3
thread.applause_ip3 = thread.applause_ip2
thread.applause_ip2 = thread.applause_ip
thread.applause_ip = self.request.remote_addr
thread.applause_date = datetime.datetime.today()
thread.search_index_version = 0
thread.put()
if bbs.applause_n:
bbs.applause_n = bbs.applause_n + 1
else:
bbs.applause_n = 1
bbs.put()
user = users.get_current_user()
comment = ""
if self.request.get("comment"):
comment = self.request.get("comment")
StackFeed.feed_new_applause_thread(user, thread, comment)
Ranking.add_rank_global(thread, BbsConst.SCORE_APPLAUSE)
if self.request.get("mode") == "bbs":
order = self.request.get("order")
page = self.request.get("page")
self.redirect(str(MappingId.get_usr_url("./", bbs) + "?order=" + order + "&page=" + page))
else:
thread_url = self.request.get("thread_key")
if thread.short:
thread_url = thread.short
self.redirect(str(MappingId.get_usr_url("./", bbs) + thread_url + ".html"))
开发者ID:abars,项目名称:illustbook,代码行数:57,代码来源:Applause.py
示例2: get
def get(self):
try:
bbs=db.get(self.request.get("bbs_key"))
except:
bbs=None
if(bbs==None):
Alert.alert_msg_notfound(self)
return
host_url=MappingId.mapping_host_with_scheme(self.request)+"/";
url=MappingId.get_usr_url(host_url,bbs)
self.redirect(str(url))
开发者ID:abars,项目名称:illustbook,代码行数:11,代码来源:RedirectBbs.py
示例3: create_user_object
def create_user_object(req,one):
#if(one.icon):
icon_url=MappingId.mapping_host_with_scheme(req.request)+"/show_icon?key="+one.user_id
#else:
# icon_url=MappingId.mapping_host_with_scheme(req.request)+"/static_files/empty_user.png"
profile_url=MappingId.mapping_host_with_scheme(req.request)+"/mypage?user_id="+one.user_id
name=one.name
if(not name):
name="noname"
one_dic={"user_id":one.user_id,"name":name,"homepage":one.homepage,"icon_url":icon_url,"profile_url":profile_url}
return one_dic
开发者ID:abars,项目名称:illustbook,代码行数:11,代码来源:ApiObject.py
示例4: get
def get(self, bbs_key):
SetUtf8.set()
bbs_key_original = bbs_key
# キャッシュに存在するか判定
result = memcache.get("feed_" + bbs_key_original)
# result=None
if not result:
# キャッシュに存在しない場合はRSS作成
# 掲示板取得
bbs_key = MappingId.mapping(bbs_key)
bbs = None
try:
bbs = db.get(bbs_key)
except:
bbs = None
if bbs == None:
self.error(404)
return
# feedを作成
result = RssFeed.generate_feed(bbs, bbs_key)
# キャッシュに入れる
memcache.set("feed_" + bbs_key_original, result, 60 * 60 * 3) # 3時間
self.response.headers["Content-Type"] = "text/xml; charset=utf-8"
self.response.out.write(result)
开发者ID:abars,项目名称:illustbook,代码行数:29,代码来源:RssFeed.py
示例5: violate_thread
def violate_thread(self):
# スレッド
thread = db.get(self.request.get("thread_key"))
if self.request.get("mode") == "adult":
if thread.adult:
thread.adult = 0
else:
thread.adult = 1
if self.request.get("mode") == "terms":
if thread.violate_terms:
thread.violate_terms = 0
else:
thread.violate_terms = 1
if self.request.get("mode") == "photo":
if thread.violate_photo:
thread.violate_photo = 0
else:
thread.violate_photo = 1
if self.request.get("mode") == "comment":
if thread.prohibit_comment:
thread.prohibit_comment = 0
else:
thread.prohibit_comment = 1
thread.put()
ApiFeed.invalidate_cache()
bbs = db.get(self.request.get("bbs_key"))
self.redirect(str(MappingId.get_usr_url("./", bbs) + self.request.get("thread_key") + ".html"))
开发者ID:abars,项目名称:illustbook,代码行数:34,代码来源:ViolationTerms.py
示例6: add_support_forum
def add_support_forum(main,app):
if(not app.support_forum and app.is_public):
thread=MesThread()
bbs_key=MappingId.mapping(BbsConst.APP_SUPPORT_BBS_ID)
if(bbs_key==""):
#return False
main.response.out.write(Alert.alert_msg("サポートフォーラムBBS[ID:"+BbsConst.APP_SUPPORT_BBS_ID+"]が見つかりません。",main.request.host))
return True
bbs=db.get(bbs_key)
thread.bbs_key=bbs
thread.title=app.app_name
thread.author=app.author
thread.summary=app.app_name+"のサポートフォーラムです。"
thread.user_id=app.user_id
thread.illust_mode=BbsConst.ILLUSTMODE_NONE
thread.create_date=datetime.datetime.today()
thread.comment_cnt=0
thread.date=datetime.datetime.today()
thread.put()
app.support_forum=thread
app.put()
#if(not app.support_forum.score):
# app.support_forum.score = None
# app.support_forum.put()
return False
开发者ID:abars,项目名称:illustbook,代码行数:30,代码来源:AppPortal.py
示例7: get_thread_list
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
开发者ID:abars,项目名称:illustbook,代码行数:30,代码来源:Ranking.py
示例8: get_thread_url
def get_thread_url(host,bbs,thread):
url=MappingId.get_usr_url(host,bbs)
if(thread.short):
url+=thread.short
else:
url+=str(thread.key())
url+=".html"
return url
开发者ID:abars,项目名称:illustbook,代码行数:8,代码来源:MappingThreadId.py
示例9: generate_feed
def generate_feed(bbs, bbs_key):
url = MappingId.get_usr_url("http://www.illustbook.net/", bbs)
feed = feedgenerator.Rss201rev2Feed(
title=bbs.bbs_name, link=url, feed_url=url, description=bbs.summary, language="ja"
)
if bbs.bbs_mode == BbsConst.BBS_MODE_NO_IMAGE:
entry_query = Entry.all().filter("bbs_key =", bbs)
entry_query.order("-date")
all_entry = entry_query.fetch(limit=20)
for entry in all_entry:
try:
thread = entry.thread_key
except:
continue
url2 = url + str(thread.key()) + ".html"
txt = "" + entry.editor + "(" + str(entry.date) + ")<BR>"
if entry.illust_reply:
txt += "<IMG SRC='http://www.illustbook.net/img?img_id='"
txt += str(entry.illust_reply_image_key.key()) + "'><BR>"
txt += entry.content
for res in entry.res_list:
response = db.get(res)
txt += "<BR><BR>" + response.editor + "(" + str(response.date) + ")<BR>"
txt += "" + response.content + "<BR>"
feed.add_item(
title=thread.title,
link=url2,
description=txt,
author_email="",
author_name=entry.editor,
author_link=entry.homepage_addr,
pubdate=entry.date,
)
else:
thread_query = MesThread.all().filter("bbs_key =", bbs)
thread_query.order("-create_date")
all_threads = thread_query.fetch(limit=20)
for thread in all_threads:
url2 = url + str(thread.key()) + ".html"
if thread.image_key:
thumbnail = "http://www.illustbook.net/img?img_id=" + str(thread.image_key.key())
feed.add_item(
title=thread.title,
link=url2,
description="<IMG SRC=" + thumbnail + "><BR>" + thread.summary,
author_email="",
author_name=thread.author,
author_link=thread.homepage_addr,
pubdate=thread.create_date,
)
result = feed.writeString("utf-8")
return result
开发者ID:abars,项目名称:illustbook,代码行数:58,代码来源:RssFeed.py
示例10: _update
def _update(self,event,user,validate_all,is_create):
event.title=self.request.get("title")
event.summary=self.request.get("summary")
if(is_create):
event.summary=EscapeComment.escape_br(event.summary)
event.summary=EscapeComment.auto_link(event.summary)
event.id=self.request.get("id")
if(event.id==""):
Alert.alert_msg_with_write(self,"IDを入力する必要があります。")
return False
if(MappingId.key_format_check(event.id)):
Alert.alert_msg_with_write(self,"IDは半角英数で16文字以下である必要があります。")
return False
try:
event.start_date=datetime.datetime.strptime(self.request.get("start_date"), '%Y/%m/%d').replace(tzinfo=JST()).astimezone(UTC())
event.end_date=datetime.datetime.strptime(self.request.get("end_date"), '%Y/%m/%d').replace(tzinfo=JST()).astimezone(UTC())
except:
Alert.alert_msg_with_write(self,"日付の変換に失敗しました。")
return False
if(event.end_date <= event.start_date):
Alert.alert_msg_with_write(self,"終了日の方が開始日より早くなっています。")
return False
event_list=Event.all().filter("start_date <=",event.end_date).order("-start_date").fetch(limit=1) #既存のDBが重複していないと仮定すると最新の1つだけチェックすればよい
for e in event_list:
if(e.id==event.id):
continue
err=False
if(e.start_date.replace(tzinfo=UTC()).astimezone(UTC()) <= event.start_date):
if(e.end_date.replace(tzinfo=UTC()).astimezone(UTC()) > event.start_date):
err=True
if(e.start_date.replace(tzinfo=UTC()).astimezone(UTC()) < event.end_date):
if(e.end_date.replace(tzinfo=UTC()).astimezone(UTC()) > event.end_date):
err=True
if(err):
mes ="今回のイベント "+str(event.start_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"〜"+str(event.end_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"<br/>";
mes+="他のイベント "+str(e.start_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"〜"+str(e.end_date.replace(tzinfo=UTC()).astimezone(JST()).strftime('%Y/%m/%d'))+"<br/>";
Alert.alert_msg_with_write(self,"日程が他のイベントと重複しています。<br/>"+mes)
return False
if(event.end_date - event.start_date > datetime.timedelta(days=BbsConst.EVENT_MAX_DAYS)):
Alert.alert_msg_with_write(self,"日程が2週間を超えています。")
return False
if(validate_all):
if(event.title=="" or event.id==""):
Alert.alert_msg_with_write(self,"タイトルとIDを入力して下さい。")
return False
if(is_create):
event.user_id=user.user_id()
if(is_create or event.user_id==user.user_id()):
event.author=self.request.get("author")
return True
开发者ID:abars,项目名称:illustbook,代码行数:57,代码来源:EventList.py
示例11: _get_bbs_url
def _get_bbs_url(req,bbs):
if(req):
bbs_url=MappingId.mapping_host_with_scheme(req.request)+"/"
else:
bbs_url="."
if(bbs.short):
bbs_url+=bbs.short+"/"
else:
bbs_url+="usr/"+str(bbs.key())+"/"
return bbs_url
开发者ID:abars,项目名称:illustbook,代码行数:10,代码来源:ApiObject.py
示例12: violate_entry
def violate_entry(self):
# エントリー
entry = db.get(self.request.get("entry_key"))
if entry.violate_terms:
entry.violate_terms = 0
else:
entry.violate_terms = 1
entry.put()
bbs = db.get(self.request.get("bbs_key"))
self.redirect(str(MappingId.get_usr_url("./", bbs) + self.request.get("thread_key") + ".html"))
开发者ID:abars,项目名称:illustbook,代码行数:11,代码来源:ViolationTerms.py
示例13: get
def get(self):
host_url=MappingId.mapping_host_with_scheme(self.request)+"/"
page = 1
if(self.request.get("page")):
page=int(self.request.get("page"))
template_values = {
'host': host_url,
'page': page
}
path = '/html/comic.html'
self.response.out.write(template_select.render(path, template_values))
开发者ID:abars,项目名称:illustbook,代码行数:12,代码来源:Comic.py
示例14: get
def get(self):
SetUtf8.set()
is_english=CssDesign.is_english(self)
short=self.request.get('id')
if(MappingId.key_format_check(short)):
txt="IDは半角英数である必要があります。"
if(is_english):
txt="ID must be 16 characters or less"
Alert.alert_msg_with_write(self,txt)
return
if(MappingId.check_capability(short,"")==0):
txt="ID:"+short+"は既に登録されていて利用できません。"
if(is_english):
txt="ID:"+short+" is not available"
Alert.alert_msg_with_write(self,txt)
return
txt="ID:"+short+"は利用可能です。"
if(is_english):
txt="ID:"+short+" is available"
Alert.alert_msg_with_write(self,txt)
开发者ID:abars,项目名称:illustbook,代码行数:22,代码来源:CheckId.py
示例15: get
def get(self):
user = users.get_current_user()
user_name=ShowEntry.get_user_name(user)
bbs_list=[]
if(user):
user_id=user.user_id()
bookmark_bbs_list=ApiBookmark.bookmark_get_bbs_list(self,user_id)
rental_bbs_list=ApiUser.user_get_bbs_list(self,user_id)
if(rental_bbs_list):
bbs_list.extend(rental_bbs_list)
if(bookmark_bbs_list):
bbs_list.extend(bookmark_bbs_list)
sample_bbs={
"title":"サンプルお絵描き掲示板",
"key":MappingId.mapping("sample")
}
bbs_list.append(sample_bbs)
temp_key=self.request.get("temp_key")
args=None
if(temp_key):
temp=db.get(temp_key)
if(temp.args):
args=temp.args
target_bbs=self.get_target_bbs(args);
if(target_bbs):
bbs_list=target_bbs
template_values={
'host':"./",
'is_iphone':CssDesign.is_iphone(self),
'is_tablet':CssDesign.is_tablet(self),
'is_english':CssDesign.is_english(self),
'temp_key':temp_key,
'redirect_url':self.request.path+"?temp_key="+temp_key,
'user':user,
'bbs_list':bbs_list,
'args':args,
'user_name':user_name
}
render=template_select.render("/html/upload_temp.html", template_values)
self.response.out.write(render)
开发者ID:abars,项目名称:illustbook,代码行数:49,代码来源:UploadTemp.py
示例16: post
def post(self,mode_url):
mode=self.request.get("mode")
user = users.get_current_user()
if(not user):
Alert.alert_msg_with_write(self,"ログインが必要です。")
return
msg=""
if(mode=="add"):
if(Event.all().filter("id =",self.request.get("id")).count()>=1):
Alert.alert_msg_with_write(self,"このIDのイベントは既に存在しています")
return
event=Event()
if(not self._update(event,user,True,True)):
return
event.put()
if(mode=="edit"):
event=Event.all().filter("id =",self.request.get("id")).fetch(limit=2)
if(not event or len(event)==0):
Alert.alert_msg_with_write(self,"イベントが存在しません")
return
if(len(event)>=2):
Alert.alert_msg_with_write(self,"イベントが重複しています")
return
event=event[0]
if(not self._update(event,user,True,False)):
return
event.put()
if(mode=="del"):
event=Event.all().filter("id =",self.request.get("id")).fetch(limit=2)
if(not event or len(event)==0):
Alert.alert_msg_with_write(self,"イベントが存在しません")
return
event[0].delete()
host=MappingId.mapping_host_with_scheme(self.request)+"/"
if(mode=="del"):
self.redirect(str(host+"?order=event"))
else:
self.redirect(str(host+"?order=event&event_id="+event.id))
开发者ID:abars,项目名称:illustbook,代码行数:46,代码来源:EventList.py
示例17: create_bbs_object
def create_bbs_object(req,bbs):
if(not bbs):
return None
bookmark_cnt=0
if(bbs.bookmark_count):
bookmark_cnt=bbs.bookmark_count
bbs_url=ApiObject._get_bbs_url(req,bbs)
thumbnail_url=""
if(bbs.cached_thumbnail_key and not bbs.del_flag):
thumbnail_url=MappingId.mapping_host_with_scheme(req.request)+"/thumbnail/"+bbs.cached_thumbnail_key+".jpg"
summary=ApiObject.truncate_html(bbs.summary,20)
one_dic={"title":bbs.bbs_name,"summary":summary,"bbs_url":bbs_url,"bookmark":bookmark_cnt,"key":str(bbs.key()),"thumbnail_url":thumbnail_url,"mode":bbs.bbs_mode}
return one_dic
开发者ID:abars,项目名称:illustbook,代码行数:18,代码来源:ApiObject.py
示例18: feed_get_thread_list
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
开发者ID:abars,项目名称:illustbook,代码行数:44,代码来源:ApiFeed.py
示例19: redirect_main
def redirect_main(self):
#リダイレクト
host=MappingId.mapping_host_with_scheme(self.request)+"/";
redirect_url=host+"mypage?";
#リダイレクト先は必ず自分とする(他人のタイムラインには投稿は表示されないので)
#if(self.request.get("to_user_id")):
# redirect_url=redirect_url+"&user_id="+self.request.get("to_user_id")
if(self.request.get("feed_page")):
redirect_url=redirect_url+"&feed_page="+self.request.get("feed_page")
if(self.request.get("tab")):
redirect_url=redirect_url+"&tab="+self.request.get("tab")
else:
redirect_url=redirect_url+"&tab=feed"
if(self.request.get("edit")):
redirect_url=redirect_url+"&edit="+self.request.get("edit")
self.redirect(str(redirect_url))
开发者ID:abars,项目名称:illustbook,代码行数:19,代码来源:StackFeedTweet.py
示例20: get
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)
#掲示板のデザインを取得
#.........这里部分代码省略.........
开发者ID:abars,项目名称:illustbook,代码行数:101,代码来源:ShowThread.py
注:本文中的myapp.MappingId.MappingId类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论