appengine bulkdownloader to xml with nested entiti

2019-04-11 02:49发布

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 using 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

1条回答
神经病院院长
2楼-- · 2019-04-11 03:18

Try using:

transform.list_from_child_node('GradingPeriods/GradingPeriod', suppress_blank=True)
查看更多
登录 后发表回答