本文整理汇总了Python中rogerthat.rpc.models.Mobile.create_key方法的典型用法代码示例。如果您正苦于以下问题:Python Mobile.create_key方法的具体用法?Python Mobile.create_key怎么用?Python Mobile.create_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rogerthat.rpc.models.Mobile
的用法示例。
在下文中一共展示了Mobile.create_key方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_unread_messages
# 需要导入模块: from rogerthat.rpc.models import Mobile [as 别名]
# 或者: from rogerthat.rpc.models.Mobile import create_key [as 别名]
def _create_unread_messages(stats, language, server_settings, user_profile):
sender_users = list({s[0] for s in stats[1] if s[0] != MC_DASHBOARD})
sender_profile_infos = dict(zip(sender_users, get_profile_infos(sender_users, allow_none_in_results=True)))
timezone_diff = 0
if user_profile.mobiles:
for mobile_detail in user_profile.mobiles:
mobile = Mobile.get(Mobile.create_key(mobile_detail.account))
timezone_diff = mobile.timezoneDeltaGMT or 0
break
avatars = dict() # { avatar_id : (avatar_data) }
def get_avatar_url(avatar_id):
avatar = avatars.get(avatar_id)
if not avatar:
if avatar_id in ('nuntiuz', 'unknown'):
if avatar == 'nuntiuz':
avatar = UNKNOWN_AVATAR
else:
avatar = NUNTIUZ_AVATAR
else:
avatar = get_avatar_cached(avatar_id, size=40)
avatars[avatar_id] = avatar
return 'cid:%s' % avatar_id
unread_messages = list() # sorted by message.creationTimestamp
for sender_user, message, broadcast_type, creation_time in sorted(stats[1], key=lambda x: x[3]):
sender_profile_info = sender_profile_infos.get(sender_user)
if sender_profile_info:
name = sender_profile_info.name
avatar_url = get_avatar_url(sender_profile_info.avatarId)
elif sender_user == MC_DASHBOARD:
name = get_profile_info_name(sender_user, user_profile.app_id)
avatar_url = get_avatar_url('nuntiuz')
else:
name = sender_user.email().split(':', 1)[0].split('/', 1)[0]
avatar_url = get_avatar_url('unknown')
creation_date_time = datetime.datetime.utcfromtimestamp(creation_time + timezone_diff)
creation_time_str = '%s, %s' % (format_date(creation_date_time, locale=language, format='short'),
format_time(creation_date_time, locale=language, format='short'))
if broadcast_type:
sender_user = add_slash_default(sender_user)
if len(name) > 43:
name = name[:40] + u'...'
unread_messages.append(UnreadMessage(name, avatar_url, message, broadcast_type, creation_time_str,
localize(language, 'email_reminder_unsubscribe_caption',
notification_type=xml_escape(broadcast_type) if broadcast_type else None,
service=xml_escape(name)),
generate_unsubscribe_broadcast_link(user_profile.user, sender_user, name,
broadcast_type)))
return unread_messages, avatars
示例2: push_app_settings_to_user
# 需要导入模块: from rogerthat.rpc.models import Mobile [as 别名]
# 或者: from rogerthat.rpc.models.Mobile import create_key [as 别名]
def push_app_settings_to_user(user_profile, app_id):
app_settings = get_app_settings(app_id)
if user_profile.mobiles:
mobiles = db.get([Mobile.create_key(mobile_detail.account) for mobile_detail in user_profile.mobiles])
for mobile in mobiles:
mobile_settings = get_mobile_settings_cached(mobile)
mobile_settings.version += 1
mobile_settings.put()
request = UpdateSettingsRequestTO()
request.settings = SettingsTO.fromDBSettings(app_settings, user_profile, mobile_settings)
updateSettings(update_settings_response_handler, logError, mobile.user, request=request)
示例3: push_app_settings_to_user
# 需要导入模块: from rogerthat.rpc.models import Mobile [as 别名]
# 或者: from rogerthat.rpc.models.Mobile import create_key [as 别名]
def push_app_settings_to_user(user_profile, app_id):
if user_profile.mobiles:
keys = [AppSettings.create_key(app_id)] + [Mobile.create_key(mobile_detail.account)
for mobile_detail in user_profile.mobiles]
entities = db.get(keys)
app_settings = entities.pop(0)
for mobile in entities:
mobile_settings = mobile.settings()
mobile_settings.version += 1
mobile_settings.put()
request = UpdateSettingsRequestTO()
request.settings = SettingsTO.fromDBSettings(mobile_settings, app_settings)
updateSettings(update_settings_response_handler, logError, mobile.user, request=request)