Thanks Ikai. The approach you suggested for exporting the key field worked for me.
Len On Nov 19, 5:36 pm, "Ikai L (Google)" <ika...@google.com> wrote: > Len, > > I assume you are doing this by having different application versions for a > Python application and Java application as documented here: > > http://googleappengine.blogspot.com/2009/06/10-things-you-probably-di... > > Then redefining your Java data class in Python in your Exporter class and > passing a string similar to this to appcfg.py: > > appcfg.py --server=python.latest.YOURAPPID.appspot.com download_data APPDIR > --filename=output.csv --kind=Thing --config_file=APPDIR/thing_exporter.py > > There's a trick you'll need to export the key. Here's my Thing.java > (http://pastie.org/706983): > > import com.google.appengine.api.datastore.Key; > import javax.jdo.annotations.*; > > @PersistenceCapable(identityType = IdentityType.APPLICATION) > public class Thing { > > @PrimaryKey > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > private Key key; > > @Persistent > private String name; > > @Persistent > private int number; > > public Thing(String name, int number) { > this.name = name; > this.number = number; > } > > public Key getKey() { > return key; > } > > public String getName() { > return name; > } > > public void setName(String name) { > this.name = name; > } > > public int getNumber() { > return number; > } > > public void setNumber(int number) { > this.number = number; > } > > } > > Here's the corresponding Python exporter code (http://pastie.org/706981): > > from google.appengine.ext import db > from google.appengine.tools import bulkloader > > class Thing(db.Model): > name = db.StringProperty() > number = db.IntegerProperty() > > def AddKeys(entity_generator): > for entity in entity_generator: > entity['key'] = entity.key() > yield entity > > class ThingExporter(bulkloader.Exporter): > def __init__(self): > bulkloader.Exporter.__init__(self, 'Thing', > [('key', str, None), > ('name', str, None), > ('number', str, None) > ]) > > def output_entities(self, entity_generator): > bulkloader.Exporter.output_entities(self, AddKeys(entity_generator)) > > exporters = [ThingExporter] > > The magic here is in the AddKey that you define. You add the "key" field to > the objects in each iteration of your loop exporting an entity. > > > > > > On Fri, Nov 13, 2009 at 4:15 PM, lent <lentakeu...@gmail.com> wrote: > > Hello, > > > I got python bulkloader upload data and download data working with > > loader and exporter for my java app. Do the bulkloader dump and > > restore options work when used with java app? They don't seem to work > > for me. I get an error like: > > BadRequestError: app xxx cannot access app bulkload.latest.xxx's data > > > When doing download data, how can I get the id field exported, i.e. > > what do you need to specify in the exporter to export the id field? I > > tried field names such as key and id (of type db.Key) but they didn't > > work. > > > Regards, > > Len > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Google App Engine for Java" group. > > To post to this group, send email to > > google-appengine-j...@googlegroups.com. > > To unsubscribe from this group, send email to > > google-appengine-java+unsubscr...@googlegroups.com<google-appengine-java%2bunsubscr...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/google-appengine-java?hl=. > > -- > Ikai Lan > Developer Programs Engineer, Google App Engine- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=.