本文整理汇总了Python中db.User.get_key方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_key方法的具体用法?Python User.get_key怎么用?Python User.get_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.User
的用法示例。
在下文中一共展示了User.get_key方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_watch_message
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import get_key [as 别名]
def send_watch_message(watches):
for mid, value in watches.items():
# store sent mids for receiving replies
user = User.get_key(mid).get()
if user is None:
key = create_user(mid)
user = key.get()
user.status = User.STAT_WAIT_REPLY
user.status_info = value
user.status_expire = utc_now()+timedelta(seconds=WATCH_REPLY_TIMEOUT*60)
user.put()
send_message(watches.keys(), u'楽しんでいますか?どのくらい飲みましたか?返信してくださいね!')
示例2: send_request_message
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import get_key [as 别名]
def send_request_message(reqs):
for mid, value in reqs.items():
# store sent mids for receiving result
user = User.get_key(mid).get()
if user is None:
key = create_user(mid)
user = key.get()
user.status = User.STAT_WAIT_RESULT
user.status_info = value
user.status_expire = utc_now()+timedelta(seconds=RESULT_TIMEOUT*60)
user.put()
send_message(reqs.keys(), u'昨日はお疲れさまでした。今日の様子はいかがですか?返信してくださいね!')
示例3: get_status
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import get_key [as 别名]
def get_status(user_id, is_peek=False):
mid = user_id
now = utc_now()
user = User.get_key(mid).get()
if user is None or user.status == User.STAT_NONE:
return (User.STAT_NONE, None)
else:
status = user.status
expire = user.status_expire
info = user.status_info
if is_peek == False:
user.status = User.STAT_NONE
user.put()
if expire < now:
# expired
return (User.STAT_NONE, None)
return (status, info)
示例4: history_drinking
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import get_key [as 别名]
def history_drinking(mid):
worst_drinking = get_worst_dinking(mid)
history_url = generate_random_url(mid)
user = User.get_key(mid).get()
if history_url is None or user is None:
return u'まだ飲みの登録がないか、参照が行えません'
user.history_url = history_url
user.history_expire = utc_now()+timedelta(minutes=HISTORY_DURATION)
user.put()
msg = ''
if worst_drinking:
msg += u'最悪の飲みは %s だったようです。\n' % \
(format_jdate(worst_drinking.start_date.
replace(tzinfo=tz_utc).astimezone(tz_jst)))
for kind in worst_drinking.summary:
msg += u' %s %d 杯\n' % (kind, worst_drinking.summary[kind])
msg += '\n'
url = service_url + '/history/' + history_url
return msg + u'過去の飲みは %s を参照ください。このURLは%d分間有効です。' % (url, HISTORY_DURATION)