我正在寻找一种方法来找到CKAN中资源的package_id.我通过resource_show动作访问资源:
resource_dict = toolkit.get_action("resource_show")(context, {"id": "my-resource"})
Run Code Online (Sandbox Code Playgroud)
生成的dict没有告诉我资源属于哪个包.它确实告诉我:
resource_dict.get("package_id", None) == None # <<< True
resource_dict["resource_group_id"] = "some-uuid"
Run Code Online (Sandbox Code Playgroud)
我可以在我的数据库中看到a resource_group确实有一个package_id属性.但是,似乎没有resource_group_show采取行动.
还有另一种方法让我从资源字典导航到其父包吗?
谢谢!
我可以在CKAN资源上附加额外内容吗?我注意到它ckan.model.Resource有一个extras属性,所以我试图用这样的东西创建一个资源:
resource = {
"package_id": "my-package-id",
"url": "http://google.com",
"name": "Google",
"extras": [
{ "key": "myextra", "value": "my extra content" }
]
}
from ckan.plugins import toolkit
toolkit.get_action("resource_create")(faked_context, resource)
Run Code Online (Sandbox Code Playgroud)
随之而来的是逻辑功能最终运行起来package_update,但失败了ValidationError: {u' junk': u'The input field __junk was not expected.'}
谢谢!