当前位置: 首页>>代码示例>>Python>>正文


Python Match.get_by_id_async方法代码示例

本文整理汇总了Python中models.match.Match.get_by_id_async方法的典型用法代码示例。如果您正苦于以下问题:Python Match.get_by_id_async方法的具体用法?Python Match.get_by_id_async怎么用?Python Match.get_by_id_async使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.match.Match的用法示例。


在下文中一共展示了Match.get_by_id_async方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _render

# 需要导入模块: from models.match import Match [as 别名]
# 或者: from models.match.Match import get_by_id_async [as 别名]
 def _render(self, match_key):
     try:
         match_future = Match.get_by_id_async(match_key)
         event_future = Event.get_by_id_async(match_key.split("_")[0])
         match = match_future.get_result()
         event = event_future.get_result()
     except Exception, e:
         self.abort(404)
开发者ID:NikhilNarayana,项目名称:the-blue-alliance,代码行数:10,代码来源:match_controller.py

示例2: _render

# 需要导入模块: from models.match import Match [as 别名]
# 或者: from models.match.Match import get_by_id_async [as 别名]
 def _render(self, match_key):
     try:
         match_future = Match.get_by_id_async(match_key)
         event_future = Event.get_by_id_async(match_key.split("_")[0])
         match = match_future.get_result()
         event = event_future.get_result()
     except Exception, e:
         return self.redirect("/error/404")
开发者ID:pyprogrammer,项目名称:the-blue-alliance,代码行数:10,代码来源:match_controller.py

示例3: accept_suggestions

# 需要导入模块: from models.match import Match [as 别名]
# 或者: from models.match.Match import get_by_id_async [as 别名]
    def accept_suggestions(self, suggestions):
        if (len(suggestions) < 1):
            return None

        matches = map(lambda match_future: match_future.get_result(),
                      [Match.get_by_id_async(suggestion.target_key) for suggestion in suggestions])

        pairs = zip(matches, suggestions)

        for match, suggestion in pairs:
            self._accept_suggestion(match, suggestion)

        matches, suggestions = zip(*pairs)

        matches = MatchManipulator.createOrUpdate(list(matches))

        return matches
开发者ID:CarterFendley,项目名称:the-blue-alliance,代码行数:19,代码来源:match_suggestion_accepter.py

示例4: get

# 需要导入模块: from models.match import Match [as 别名]
# 或者: from models.match.Match import get_by_id_async [as 别名]
    def get(self):
        self._require_login("/suggest/match/video?match=%s" % self.request.get("match_key"))

        if not self.request.get("match_key"):
            self.redirect("/", abort=True)

        match_future = Match.get_by_id_async(self.request.get("match_key"))
        event_future = Event.get_by_id_async(self.request.get("match_key").split("_")[0])
        match = match_future.get_result()
        event = event_future.get_result()

        self.template_values.update({
            "success": self.request.get("success"),
            "event": event,
            "match": match,
        })

        path = os.path.join(os.path.dirname(__file__), '../../templates/suggest_match_video.html')
        self.response.out.write(template.render(path, self.template_values))
开发者ID:BowlesCR,项目名称:the-blue-alliance,代码行数:21,代码来源:suggest_match_video_controller.py

示例5: get

# 需要导入模块: from models.match import Match [as 别名]
# 或者: from models.match.Match import get_by_id_async [as 别名]
    def get(self):
        self._require_registration()

        if not self.request.get("match_key"):
            self.redirect("/", abort=True)

        match_future = Match.get_by_id_async(self.request.get("match_key"))
        event_future = Event.get_by_id_async(self.request.get("match_key").split("_")[0])
        match = match_future.get_result()
        event = event_future.get_result()

        if not match or not event:
            self.abort(404)

        self.template_values.update({
            "status": self.request.get("status"),
            "event": event,
            "match": match,
        })

        self.response.out.write(jinja2_engine.render('suggestions/suggest_match_video.html', self.template_values))
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:23,代码来源:suggest_match_video_controller.py

示例6: post

# 需要导入模块: from models.match import Match [as 别名]
# 或者: from models.match.Match import get_by_id_async [as 别名]
    def post(self):
        self._require_login()

        match_key = self.request.get("match_key")
        match_future = Match.get_by_id_async(self.request.get("match_key"))
        youtube_url = self.request.get("youtube_url")

        youtube_id = None
        regex1 = re.match(r".*youtu\.be\/(.*)", youtube_url)
        if regex1 is not None:
            youtube_id = regex1.group(1)
        else:
            regex2 = re.match(r".*v=([a-zA-Z0-9_-]*)", youtube_url)
            if regex2 is not None:
                youtube_id = regex2.group(1)

        if youtube_id is not None:
            if youtube_id not in match_future.get_result().youtube_videos:
                year = match_key[:4]
                suggestion_id = Suggestion.render_media_key_name(year, 'match', match_key, 'youtube', youtube_id)
                suggestion = Suggestion.get_by_id(suggestion_id)
                if not suggestion or suggestion.review_state != Suggestion.REVIEW_PENDING:
                    suggestion = Suggestion(
                        id=suggestion_id,
                        author=self.user_bundle.account.key,
                        target_key=match_key,
                        target_model="match",
                        )
                    suggestion.contents = {"youtube_videos": [youtube_id]}
                    suggestion.put()
                    status = 'success'
                else:
                    status = 'suggestion_exists'
            else:
                status = 'video_exists'
        else:
            status = 'bad_url'

        self.redirect('/suggest/match/video?match_key={}&status={}'.format(match_key, status))
开发者ID:DNGros,项目名称:the-blue-alliance,代码行数:41,代码来源:suggest_match_video_controller.py

示例7: _query_async

# 需要导入模块: from models.match import Match [as 别名]
# 或者: from models.match.Match import get_by_id_async [as 别名]
 def _query_async(self):
     match_key = self._query_args[0]
     match = yield Match.get_by_id_async(match_key)
     raise ndb.Return(match)
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:6,代码来源:match_query.py


注:本文中的models.match.Match.get_by_id_async方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。