本文整理汇总了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)
示例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