本文整理汇总了Python中myapp.MappingId.MappingId类的典型用法代码示例。如果您正苦于以下问题:Python MappingId类的具体用法?Python MappingId怎么用?Python MappingId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MappingId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"))
示例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))
示例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
示例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)
示例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"))
示例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
示例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
示例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
示例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
示例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
示例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
示例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"))
示例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))
示例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)
示例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)