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


Python District.get_by_id_async方法代码示例

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


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

示例1: _query_async

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

示例2: validate_request

# 需要导入模块: from models.district import District [as 别名]
# 或者: from models.district.District import get_by_id_async [as 别名]
    def validate_request(cls, handler):
        kwargs = handler.request.route_kwargs
        error_dict = {'Errors': []}
        valid = True
        team_future = None
        event_future = None
        match_future = None
        district_future = None
        # Check key formats
        if 'team_key' in kwargs:
            team_key = kwargs['team_key']
            results = cls.team_id_validator(team_key)
            if results:
                error_dict['Errors'].append(results)
                valid = False
            else:
                team_future = Team.get_by_id_async(team_key)
        if 'event_key' in kwargs:
            event_key = kwargs['event_key']
            results = cls.event_id_validator(event_key)
            if results:
                error_dict['Errors'].append(results)
                valid = False
            else:
                event_future = Event.get_by_id_async(event_key)
        if 'match_key' in kwargs:
            match_key = kwargs['match_key']
            results = cls.match_id_validator(match_key)
            if results:
                error_dict['Errors'].append(results)
                valid = False
            else:
                match_future = Match.get_by_id_async(match_key)
        if 'district_key' in kwargs:
            district_key = kwargs['district_key']
            results = cls.district_id_validator(district_key)
            if results:
                error_dict['Errors'].append(results)
                valid = False
            else:
                district_future = District.get_by_id_async(district_key)
        if 'year' in kwargs:
            year = int(kwargs['year'])
            if year > tba_config.MAX_YEAR or year < 1992:
                error_dict['Errors'].append({'year': 'Invalid year: {}. Must be between 1992 and {} inclusive.'.format(year, tba_config.MAX_YEAR)})
                valid = False

        # Check if keys exist
        if team_future and team_future.get_result() is None:
            error_dict['Errors'].append({'team_id': 'team id {} does not exist'.format(team_key)})
            valid = False
        if event_future and event_future.get_result() is None:
            error_dict['Errors'].append({'event_id': 'event id {} does not exist'.format(event_key)})
            valid = False
        if match_future and match_future.get_result() is None:
            error_dict['Errors'].append({'match_id': 'match id {} does not exist'.format(match_key)})
            valid = False
        if district_future and district_future.get_result() is None:
            error_dict['Errors'].append({'district_id': 'district id {} does not exist'.format(district_key)})
            valid = False

        if not valid:
            return error_dict
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:65,代码来源:validation_helper.py


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