Python Eve中的双层嵌入

Python Eve中的双层嵌入,python,eve,Python,Eve,据我所知,PythonEve不支持双层嵌入,你能确认吗 为了更好地解释,给定一个文档a引用一个文档B引用一个文档C,Eve不可能嵌入a文档C,对吗 我认为这是不可能的,因为在报告中还说: 我们不支持多层嵌入 这不管用。我试过了。settings.py文件将向您显示我尝试过的双重嵌入,但它不起作用 import os from schemas.subjects import subject_schema from schemas.units import units_schema # We wan

据我所知,PythonEve不支持双层嵌入,你能确认吗

为了更好地解释,给定一个文档
a
引用一个文档
B
引用一个文档
C
,Eve不可能嵌入
a
文档
C
,对吗

我认为这是不可能的,因为在报告中还说:

我们不支持多层嵌入


这不管用。我试过了。settings.py文件将向您显示我尝试过的双重嵌入,但它不起作用

import os
from schemas.subjects import subject_schema
from schemas.units import units_schema
# We want to seamlessy run our API both locally and on Heroku. If running on
# Heroku, sensible DB connection settings are stored in environment variables.
# MONGO_URI = os.environ.get('MONGODB_URI', 'mongodb://user:user@localhost:27017/evedemo')
MONGO_HOST = 'localhost'
MONGO_PORT = 27017
MONGO_DBNAME = 'test'

# Enable reads (GET), inserts (POST) and DELETE for resources/collections
# (if you omit this line, the API will default to ['GET'] and provide
# read-only access to the endpoint).
RESOURCE_METHODS = ['GET', 'POST', 'DELETE']

# Enable reads (GET), edits (PATCH) and deletes of individual items
# (defaults to read-only item access).
ITEM_METHODS = ['GET', 'PATCH', 'DELETE']

# We enable standard client cache directives for all resources exposed by the
# API. We can always override these global settings later.
CACHE_CONTROL = 'max-age=20'
CACHE_EXPIRES = 20

# Our API will expose two resources (MongoDB collections): 'people' and
# 'works'. In order to allow for proper data validation, we define beaviour
# and structure.
people = {
    # 'title' tag used in item links.
    'item_title': 'person',

    # by default the standard item entry point is defined as
    # '/people/<ObjectId>/'. We leave it untouched, and we also enable an
    # additional read-only entry point. This way consumers can also perform GET
    # requests at '/people/<lastname>/'.
    'additional_lookup': {
        'url': 'regex("[\w]+")',
        'field': 'lastname'
    },

    # Schema definition, based on Cerberus grammar. Check the Cerberus project
    # (https://github.com/pyeve/cerberus) for details.
    'schema': {
        'id':{'type':'integer','required':True},
        'firstname': {
            'type': 'string',
            'minlength': 1,
            'maxlength': 10,
        },
        'lastname': {
            'type': 'string',
            'minlength': 1,
            'maxlength': 15,
            'required': True,
            # talk about hard constraints! For the purpose of the demo
            # 'lastname' is an API entry-point, so we need it to be unique.
            'unique': True,
        },
        # 'role' is a list, and can only contain values from 'allowed'.
        'role': {
            'type': 'list',
            'allowed': ["author", "contributor", "copy"],
        },
        # An embedded 'strongly-typed' dictionary.
        'location': {
            'type': 'dict',
            'schema': {
                'address': {'type': 'string'},
                'city': {'type': 'string'}
            },
        },
        'born': {
            'type': 'datetime',
        },
    }
}

works = {
    # if 'item_title' is not provided Eve will just strip the final
    # 's' from resource name, and use it as the item_title.
    #'item_title': 'work',

    # We choose to override global cache-control directives for this resource.
    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,

    'schema': {
        'title': {
            'type': 'string',
            'required': True,
        },
        'description': {
            'type': 'string',
        },
        'owner': {
            'type': 'objectid',
            'required': True,
            # referential integrity constraint: value must exist in the
            # 'people' collection. Since we aren't declaring a 'field' key,
            # will default to `people._id` (or, more precisely, to whatever
            # ID_FIELD value is).
            'data_relation': {
                'resource': 'people',
                # make the owner embeddable with ?embedded={"owner":1}
                'embeddable': True
            },
        },
    }
}

interests={
    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,
    'schema':{
        'interest':{
            'type':'objectid',
            'required':True,
            'data_relation': {
                'resource': 'works',
                # make the owner embeddable with ?embedded={"owner":1}
                'embeddable': True
            },
        }
    }
}

# The DOMAIN dict explains which resources will be available and how they will
# be accessible to the API consumer.
DOMAIN = {
    'people': people,
    'works': works,
    'interests':interests,
}
导入操作系统
从schemas.subjects导入subject\u schema
从schemas.units导入单位\u schema
#我们希望Seamlesy在本地和Heroku上运行我们的API。如果继续
#Heroku,合理的数据库连接设置存储在环境变量中。
#MONGO_URI=os.environ.get('MONGODB_URI','mongodb://user:user@localhost:27017/evedemo')
MONGO_主机='localhost'
MONGO_港=27017
MONGO_DBNAME='test'
#为资源/集合启用读取(获取)、插入(发布)和删除
#(如果省略这一行,API将默认为['GET'],并提供
#对端点的只读访问)。
资源_方法=['GET','POST','DELETE']
#启用单个项目的读取(获取)、编辑(修补)和删除
#(默认为只读项访问)。
ITEM_METHODS=['GET','PATCH','DELETE']
#我们为
#API。我们以后可以随时覆盖这些全局设置。
缓存\控制='最大使用年限=20'
缓存_EXPIRES=20
#我们的API将公开两种资源(MongoDB集合):“人”和
#“工作”。为了允许正确的数据验证,我们定义了beaviour
#和结构。
人={
#项目链接中使用的“title”标记。
“项目名称”:“人员”,
#默认情况下,标准项入口点定义为
#“/people/”。我们将其保持不变,并启用
#附加只读入口点。这样消费者也可以执行GET
#请求位于“/people/”。
“附加查找”:{
“url”:“regex([\w]+”,
“字段”:“lastname”
},
#架构定义,基于Cerberus语法。检查Cerberus项目
# (https://github.com/pyeve/cerberus)详情请参阅。
“架构”:{
'id':{'type':'integer','required':True},
“名字”:{
'类型':'字符串',
“minlength”:1,
“maxlength”:10,
},
“姓氏”:{
'类型':'字符串',
“minlength”:1,
“最大长度”:15,
“必需”:True,
#讨论硬约束!为了演示的目的
#“lastname”是一个API入口点,因此我们需要它是唯一的。
“独特”:正确,
},
#“角色”是一个列表,只能包含“允许”中的值。
“角色”:{
“类型”:“列表”,
“允许”:[“作者”、“贡献者”、“副本”],
},
#嵌入的“强类型”词典。
“地点”:{
'type':'dict',
“架构”:{
'地址':{'type':'string'},
'城市':{'type':'string'}
},
},
“出生”:{
“类型”:“日期时间”,
},
}
}
作品={
#如果未提供“项目标题”,Eve将仅删除最终标题
#从资源名称中选择“s”,并将其用作项目标题。
#“项目名称”:“工作”,
#我们选择覆盖此资源的全局缓存控制指令。
“缓存控制”:“最大使用期限=10,必须重新验证”,
'cache_expires':10,
“架构”:{
“标题”:{
'类型':'字符串',
“必需”:True,
},
“说明”:{
'类型':'字符串',
},
“所有者”:{
'type':'objectid',
“必需”:True,
#引用完整性约束:值必须存在于
#“人员”集合。由于我们没有声明“字段”键,
#将默认为“people.\u id”(或者更准确地说,默认为“which”)
#ID_字段值为)。
“数据关系”:{
“资源”:“人”,
#使用?embedded={“owner”:1}使所有者可嵌入
“可嵌入”:True
},
},
}
}
兴趣={
“缓存控制”:“最大使用期限=10,必须重新验证”,
'cache_expires':10,
“架构”:{
“利息”:{
'type':'objectid',
“必需”:True,
“数据关系”:{
“资源”:“工作”,
#使用?embedded={“owner”:1}使所有者可嵌入
“可嵌入”:True
},
}
}
}
#域dict解释了哪些资源可用以及如何使用
#API使用者可以访问。
域={
"人":人,,
“作品”:作品,
"利益":利益,,
}
终点: {“业主”:1}个工程


{“兴趣”:1}&embedded={“所有者”:1}没有返回所需的结果。

您的问题似乎已经得到了回答。你对社区有什么要求?我要求确认。也许有人对代码很有信心,或者她对这个问题有一些经验。我同意这可能看起来很愚蠢,如果问题结束,我不会感到惊讶