get_by_id issue?

36 views
Skip to first unread message

gwstuff

unread,
Jun 23, 2011, 12:39:21 AM6/23/11
to google-a...@googlegroups.com
Hi,

I am having trouble getting get_by_id working on the latest version of dev_appserver. Is anyone else facing this issue with the latest release?

Input (on the interactive console):

from db.note import Note

n = Note.all()[0]
i = n.key().id()
print i
print Note.get_by_id(i)

Output:

3
None




Robert Kluin

unread,
Jun 24, 2011, 3:51:31 PM6/24/11
to google-a...@googlegroups.com
Strange, your code works fine for me. This also works for me:

class Test(db.Model):
pass

t_key = Test().put()
t_id = t_key.id()
print type(t_id), t_id

t = Test.get_by_id(t_id)
print str(t.key())


Robert

> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine/-/m7PrC_1KLQgJ.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengi...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>

Raymond C.

unread,
Jun 24, 2011, 11:45:39 PM6/24/11
to google-a...@googlegroups.com
do it has a parent entity which makes get_by_id failed?

gwstuff

unread,
Jun 27, 2011, 9:44:20 PM6/27/11
to google-a...@googlegroups.com
Yes, that was it. I realized it while debugging my problem further the next day. I was wrongly assuming that ids are unique - they are in fact only unique given the path of the parent entity. For my purpose, using a full key is more appropriate.
Reply all
Reply to author
Forward
0 new messages