代码之家  ›  专栏  ›  技术社区  ›  Riley Lark

appengine bulkdownloader到具有嵌套实体的xml

  •  3
  • Riley Lark  · 技术社区  · 14 年前

    我有一个appengine应用程序,它有两种简单的实体- ParentEntity ChildEntity s每个 父实体 有一个 List 拥有的 儿童实体 s

    @PersistenceCapable
    public class ParentEntity
    {
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;
    
        @Persistent
        private String name;
    
        @Persistent(defaultFetchGroup=true)
        private List<ChildEntity> children;
    
    ...
    

    具有类似定义的子实体。

    现在,我想使用中描述的技术从数据存储中下载所有数据 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_数据的嵌套XML中

    1 回复  |  直到 14 年前
        1
  •  0
  •   Peter Knego    14 年前

    transform.list_from_child_node('GradingPeriods/GradingPeriod', suppress_blank=True)