GoogleCloudPlatform / datastore-ndb-python

Client library for use with Google Cloud Datastore from within the Google App Engine Python runtime.
https://cloud.google.com/appengine/docs/standard/python/ndb/
Apache License 2.0
114 stars 48 forks source link

NDB.Key Method Needs Method for Getting Keys by "urlsafe" and "kind" #263

Open bgreeley opened 8 years ago

bgreeley commented 8 years ago

When converting urlsafe versions of keys to actual keys, there is a method to get by urlsafe string, but not one for urlsafe string and kind. It would be nice to have a method like:

ndb.Key(urlsafe='urlsafe_string', kind='Car')

... instead of having to do:

key = ndb.Key(urlsafe='urlsafe_string') if key.kind() != Car.name: key = None

Just to verify that the key being returned is the expected type.

beaverkiria commented 7 years ago

This requirement seems to be illogical, because urlsafe string contains information about model kind and key id encoded in base64.