Google Appengine: odd behavior get_by_key_name

UPDATE: after further testing, it seems that this problem affects all children in my entity group. My root parent for all of these different instances is the type of user, which is my own creation, not the built-in user. After removing parent = user from the constructor of the child Kind, the name get_by_key_ works as expected. However, I would like to be able to use the functionality of the Entity group along with certain keys, if possible.

- Hello, I am trying to use certain key names for a faster query in my GAE project.

However, I ran into an odd problem when I cannot get the key. This code does not work:

for l in Logins.all().fetch():
    print Login.get_by_key_name(l.key().name())

Some notes:

  • I tested only in the SDK
  • l.key (). name () Returns the key name string specified in the object when I look in the data store. I can copy and paste a row from the data history and use it as arg for get_by_key_name (), and this also does not work.

  • The keyword for the Login type is prefixed with "l" (ie, lowercase "L"), while others are all lowercase letters and can contain underscores or dashes, but no more than 500 bytes.

  • Other types such as this work.

  • The key is the interpolation of two properties of type Login, and I can get the objects just fine using the usual .filter () methods
  • Parent for instances is the user class. (a mention in case this has something to do with how I should get it)

, , ? SDK?

+3
1

, AFAIK. / . () /parents/[parent_keyname]/logins/[login_keyname]. , /logins/[login_keyname], . ( , Login Parent s; `get_by_key_name() .)

Key.from_path(). , . Login.key_for_name(some_parent, some_name), Login.get_by_key_name_for_parent(some_parent, some_name) (, , ). , /.

+3

Source: https://habr.com/ru/post/1730906/


All Articles