GAE datastore cached entities under Python objects

30 views
Skip to first unread message

Cosmin Poieană

unread,
Jun 7, 2017, 9:57:57 AM6/7/17
to Google App Engine
I have this code here: http://sprunge.us/TAjH?py

Why am I getting 10 instead of 1 (or what is in the DB)? Also, any new retrieved python object (as entity) has the very same ID (and maybe even memory address). Why that? How should I proceed in order to have different objects with the real value stored under the DB?

Yannick (Cloud Platform Support)

unread,
Jun 8, 2017, 10:15:22 AM6/8/17
to google-a...@googlegroups.com
Hello Cosmin. Your code at line 22 behaves as expected, retrieving the last value that was saved to the Datastore, that last value being 1. When you set "nr" to 10 on line 21 you're only affecting the local copy of the model and the changes won't be reflected to the datastore until you perform another put operation on this entity.

Regarding the ID of Datastore entities, refer to this documentation to learn how to specify your own, if that's what you want to do.
Reply all
Reply to author
Forward
0 new messages