If you want to get multiple objects with a list of ids and it only works if they have the same parent then it is a bug, if the parent parameter of Model.get_by_id([1,2,3],parent=None) is None. The code of Model.get_by_id(ids) only constructs a list of keys with db.Key.from_path and calls db.get(keys) The "having same parent" is only needed if you specify the parent parameter of the Model.get_by_id([1,2,3],parent=aparent) call.
There is a small type in the doc for Model.get_by_id(ids) : http://code.google.com/appengine/docs/python/datastore/modelclass.html#Model_get_by_id "If ids is a string representing one name, " should be "If ids is an integer representing one id, " ---- And the doc string for Model.get_by_id(ids) refers to a parameter "key_names", that should be "ids" 2010/1/30 dburns <drrnb...@gmail.com>: > You're right, it's not entirely clear why Model.get_by_id(ids) > requires all entities to have the same parent, while Model.get(keys) > doesn't have that requirement. Presumably some implementation > detail. But whatever the reason, using Model.get(keys) is a good > idea. I'll give that a shot when I get a chance. Thanks for the > idea! > > On Jan 29, 4:06 pm, Danny Tuppeny <da...@tuppeny.com> wrote: >> I don't know if I was drunk when I sent this message, but I don't >> think it makes any sense at all. If you're calling get() on SS, it's >> quite clear what the kind is! >> >> On Jan 28, 7:20 am, Danny Tuppeny <da...@tuppeny.com> wrote: >> >> > On Jan 24, 12:29 am, dburns <drrnb...@gmail.com> wrote: >> >> > > Making a User instance the parent of a SS (snapshot) instance seems >> > > like a natural fit, except then I can't fetch all the favourites via: >> > > favs = SS.get_by_id(user.fav_ids). The reason is that all parents >> > > have to be the same to use SS.get_by_id (according >> > > tohttp://code.google.com/appengine/docs/python/datastore/modelclass.htm...), >> > > but those favourites may have been created by various users (hence the >> > > parents would be different). >> >> > Can you use SS.get(keys) instead? >> >> > I think the reason that get_by_id requires the parent is because IDs >> > are not full keys (and presumably an ID can be duplicated for >> > different kinds). If you create Keys for them (you'll need to know >> > their Kind), you could call SS.get(keys) and get them all in one go. >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To post to this group, send email to google-appeng...@googlegroups.com. > To unsubscribe from this group, send email to > google-appengine+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/google-appengine?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.