开发者

appengine bulkdownloader to xml with nested entities

I've got an appengine app with two simple kinds of entities - ParentEntitys and ChildEntitys. Each ParentEntity has a List of owned ChildEntitys.

@PersistenceCapable
public class ParentEntity
{
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

    @Persistent
    private String name;

    @Persistent(defaultFetchGroup=true)
    private List<ChildEntity> children;

...

With ChildEntity similarly defined.

Now, I want to download all of my data from the datastore usin开发者_运维问答g the technique described at http://bulkloadersample.appspot.com/ . In their example they manage to export data to an xml file with owned entities nested inside parent entities. But when I try to use the following configuration (which very closely resembles theirs - see http://bulkloadersample.appspot.com/showfile/bulkloader_visitactivity.yaml and look at the activities property), I'm met with errors.

- 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

I get the following error:

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

Big update:

I've created this sample app that you can actually view and download and test

at http://rileylark.appspot.com

You can see the output I WANT at http://rileylark.appspot.com/view

Download the eclipse project to see how it works.

What I want for my 500 points is a working config.yaml file that can export the data for Parent and ChildEntities into nested XML with appcfg.py download_data


Try using:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜