bulkload_client key_name & parent not possible?

6 views
Skip to first unread message

Angel

unread,
Aug 13, 2008, 9:42:03 PM8/13/08
to Google App Engine
Hi,
Using the bulkload_client, I found no way to set a key_name or parent
relation for entities. Are these features planned? Or are they already
in there and I am missing something. For example:

#models.py
class Foo(db.Model):
name = db.StringProperty()

class Bar(db.Model):
name = db.StringProperty()
foo = db.ReferenceProperty(Foo)

#foo.py
from google.appengine.ext import bulkload
foo = bulkload.Loader('Foo',
[('name',str),
])

if __name__ == '__main__':
bulkload.main(foo)

# bar.py
from google.appengine.ext import bulkload
from models import Foo

class BarLoader(bulkload.Loader):
def __init__(self):
bulkload.Loader.__init__(self,'Bar',
[('name',str),
('foo',str),
])
def HandleEntity(self, entity):
f = Foo.all().filter("name =", entity['foo']).get()
entity['parent'] = f.key() # doesn't work
entity['key_name'] = entity['name'] # doesn't work
entity['foo'] = f.key() # works fine
return entity
if __name__ == '__main__':
bulkload.main(BarLoader())

ilial

unread,
Aug 14, 2008, 7:49:58 AM8/14/08
to Google App Engine
Hi,

Here's my HandleEntity. Hope that helps.

def HandleEntity(self, entity):
# setup a unique key for the entity. composed of agency_name +
reference_number
name = entity['agency_name']+entity['reference_number']
logging.debug("name="+name)
newent = datastore.Entity('Contract', name=name)
newent.update(entity)
ent = search.SearchableEntity(newent)
return ent

Akume

unread,
Sep 28, 2008, 4:00:48 PM9/28/08
to Google App Engine
does that mean you have two of the same entry in the datastore now
though?
shouldn't you remove 'entity' after you've put it's values into
'newent'?

-akume
Reply all
Reply to author
Forward
0 new messages