pythongoogle-app-enginegoogle-cloud-datastorebulkloader

How to config export property db.ListProperty(db.Key) in bulkloader


I started to export data from Google AppEngine with bulkLoader, configured in bulkloader.yaml. For "standard" data likes string, int and bool this is no problem. Even single keys are exported easily.

Now I have some data db.ListProperty(db.Keys) and the export fails. In export_transform I tried, see ??? in bulkloader_config.yaml below:

Any idea how to export the list of keys?

datamodel.py

    class Receipt(db.Model):
    coupons = db.ListProperty(db.Key) # only coupon ids of approved coupons

bulkloader_config.yaml

    - kind: Receipt
      connector: csv
      connector_options:
        columns: from_header
      property_map:
        - property: __key__
          export_transform: transform.key_id_or_name_as_string
        - property: coupons
          import_transform: transform.create_foreign_key('Coupon')
          export_transform: transform.???

Solution

  • I have to do a little hack but it works

      def prop_name_converter(obj):
        if not obj:
          return ''
        str_list = []
        for o in obj:
          str_list.append(`o`)
        return ''.join(str_list)