def _check_access_resource_ids(self, func, resources):
"""
Check resource identified by an ID exist and then call func for
each resource
"""
if not resources:
raise Return()
for resource_id in resources:
try:
doc = yield views.service_and_repository.first(key=resource_id)
except couch.NotFound:
raise InvalidScope('Scope contains an unknown resource ID')
resource = RESOURCE_TYPES[doc['value']['type']](**doc['value'])
try:
yield resource.get_parent()
except couch.NotFound:
raise InvalidScope('Invalid resource - missing parent')
func(resource, resources[resource_id])
评论列表
文章目录