def construct_collection(self, instance, spec, loc, context):
"""
Constructor for `.collection` predicate.
This constructor aims to aggregate the cerberus validation schemas
for every single field defined by the collection.
"""
instance = super(self.__class__, self).construct_collection(
instance, spec, loc, context)
self.init_adapter_conf(instance)
schema = {field_name: schema.get(self.ADAPTER_CONF, {})
for field_name, schema in doc.doc_get(
instance, ('*',)).iteritems()}
collection = context.get('parent_name')
endpoint = urljoin(
self.root_url, TRAILING_SLASH.join([loc[0], collection]))
endpoint += TRAILING_SLASH
instance[self.ADAPTER_CONF] = schema
client = ApimasClient(endpoint, schema)
self.clients[loc[0] + '/' + collection] = client
return instance
评论列表
文章目录