adapter.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:apimas 作者: grnet 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号