In general, it is best to make one request against many requests for a given object. Let's say I have a bunch of "son" objects, each with a "father". I get all the "son" objects:
sons = Son.all()
Then I would like to get all the fathers for this group of sons. I:
father_keys = {} for son in sons: father_keys.setdefault(son.father.key(), None)
Then I can do:
fathers = Father.get(father_keys.keys())
Now this assumes that son.father.key () does not actually fetch the object. Am I really wrong? I have a bunch of code that assumes that object.related_object.key () does not actually retrieve the associated_object from the data store.
Am I doing it right?
python google-app-engine google-cloud-datastore
sotangochips
source share