Appengine bulkdownloader in xml with nested objects

I have an appengine application with two simple entity types - ParentEntityand ChildEntitys. Everyone ParentEntityhas Listowned 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 my data from the data warehouse using the technique described at http://bulkloadersample.appspot.com/ . In their example, they manage to export data to an XML file with their own objects embedded in parent objects. But when I try to use the following configuration (which is very similar to them: see http://bulkloadersample.appspot.com/showfile/bulkloader_visitactivity.yaml and look at the property activities), I encountered 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 created this sample application that you can really view and download and test.

at http://rileylark.appspot.com

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

Download the eclipse project to find out how it works.

What I want for my 500 points is a working config.yaml file that can export data for parent and child elements to an embedded XML file using appcfg.py download_data p>

+3
source share
1 answer

Try using:

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

Source: https://habr.com/ru/post/1775940/


All Articles