【发布时间】:2010-11-20 04:05:56
【问题描述】:
我有一个包含两种简单实体的 appengine 应用程序 - ParentEntitys 和 ChildEntitys。每个ParentEntity 都有一个List 拥有ChildEntitys。
@PersistenceCapable
public class ParentEntity
{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private String name;
@Persistent(defaultFetchGroup=true)
private List<ChildEntity> children;
...
与 ChildEntity 类似定义。
现在,我想使用http://bulkloadersample.appspot.com/ 中描述的技术从数据存储区下载我的所有数据。在他们的示例中,他们设法将数据导出到 xml 文件,其中拥有的实体嵌套在父实体中。但是当我尝试使用以下配置时(与他们的配置非常相似 - 请参阅 http://bulkloadersample.appspot.com/showfile/bulkloader_visitactivity.yaml 并查看 activities 属性),我遇到了错误。
- kind: ParentEntity
connector: simplexml
connector_options:
xpath_to_nodes: /Parents/ParentEntity
style: element_centric
property_map:
- property: __key__
external_name: key
export_transform: transform.key_id_or_name_as_string
- property: children
external_name: Children
import_transform:
transform.list_from_child_node('Children/ChildEntity')
export_transform:
transform.child_node_from_list('ChildEntity')
- kind: ChildEntity
connector: simplexml
connector_options:
xpath_to_nodes: /Children/ChildEntity
style: element_centric
property_map:
- property: __key__
external_name: key
export_transform: transform.key_id_or_name_as_string
我收到以下错误:
google.appengine.ext.bulkload.bulkloader_errors.ErrorOnTransform: Error on trans
form. Property: children External Name: Children. Code: transform.ch
ild_node_from_list('ChildEntity') Details: 'NoneType' object is not iterable
大更新:
我创建了这个示例应用程序,您可以在http://rileylark.appspot.com 上实际查看、下载和测试
你可以在http://rileylark.appspot.com/view看到我想要的输出
下载 eclipse 项目,看看它是如何工作的。
我想要的 500 分是一个有效的 config.yaml 文件,它可以使用 appcfg.py download_data 将 Parent 和 ChildEntities 的数据导出到嵌套 XML 中
【问题讨论】:
-
你为什么使用 transform.child_node_from_list('GradingPeriod') 而不是 transform.list_from_child_node('GradingPeriod') 链接示例中使用的?
-
我做这件事的预感应该是这样。我在任何地方都没有看到任何权威文档,其他一些网站使用 child_node_from_list,似乎我想从列表中创建一个子节点。我也尝试过 list_from_child_node,但出现了一堆其他错误。
-
从中获取
children的“列表”似乎总是None。 -
很奇怪,对吧?不应该是充满了 ChildEntities 吗?
标签: google-app-engine google-cloud-datastore