本文整理汇总了Python中models.team.Team.get_by_id_async方法的典型用法代码示例。如果您正苦于以下问题:Python Team.get_by_id_async方法的具体用法?Python Team.get_by_id_async怎么用?Python Team.get_by_id_async使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.team.Team
的用法示例。
在下文中一共展示了Team.get_by_id_async方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import get_by_id_async [as 别名]
def get(self):
team_key = self.request.get("team_key")
year_str = self.request.get("year")
self._require_login("/suggest/team/media?team_key=%s&year=%s" % (team_key, year_str))
if not team_key or not year_str:
self.redirect("/", abort=True)
year = int(year_str)
team_future = Team.get_by_id_async(self.request.get("team_key"))
team = team_future.get_result()
media_key_futures = Media.query(Media.references == team.key, Media.year == year).fetch_async(500, keys_only=True)
media_futures = ndb.get_multi_async(media_key_futures.get_result())
medias_by_slugname = MediaHelper.group_by_slugname([media_future.get_result() for media_future in media_futures])
self.template_values.update({
"success": self.request.get("success"),
"team": team,
"year": year,
"medias_by_slugname": medias_by_slugname
})
path = os.path.join(os.path.dirname(__file__), '../../templates/suggest_team_media.html')
self.response.out.write(template.render(path, self.template_values))
示例2: get
# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import get_by_id_async [as 别名]
def get(self):
team_key = self.request.get("team_key")
year_str = self.request.get("year")
self._require_registration()
if not team_key or not year_str:
self.redirect("/", abort=True)
year = int(year_str)
team_future = Team.get_by_id_async(self.request.get("team_key"))
team = team_future.get_result()
if not team:
self.redirect("/", abort=True)
media_key_futures = Media.query(Media.references == team.key, Media.year == year).fetch_async(500, keys_only=True)
social_media_future = media_query.TeamSocialMediaQuery(team.key.id()).fetch_async()
media_futures = ndb.get_multi_async(media_key_futures.get_result())
medias = [media_future.get_result() for media_future in media_futures]
medias_by_slugname = MediaHelper.group_by_slugname(medias)
social_medias = sorted(social_media_future.get_result(), key=MediaHelper.social_media_sorter)
social_medias = filter(lambda m: m.media_type_enum == MediaType.INSTAGRAM_PROFILE, social_medias) # we only allow IG media, so only show IG profile
self.template_values.update({
"medias_by_slugname": medias_by_slugname,
"social_medias": social_medias,
"status": self.request.get("status"),
"team": team,
"year": year,
})
self.response.out.write(jinja2_engine.render('suggestions/suggest_team_media.html', self.template_values))
示例3: _query_async
# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import get_by_id_async [as 别名]
def _query_async(self):
team_key = self._query_args[0]
team = yield Team.get_by_id_async(team_key)
raise ndb.Return(team)