Provide a method to convert ndb Key's urlsafe format to/from datastore.Key
See original GitHub issueIn GAE standard, ndb has the concept of the urlsafe string version of a Key.
e.g. url_string = sandy_key.urlsafe()
produces a result like agVoZWxsb3IPCxIHQWNjb3VudBiZiwIM
.
However, I cannot find a way to use this format with the google.cloud.datastore library for code running outside GAE standard. Please add a method to the Key class to create urlsafe strings and a method to generate Keys from urlsafe strings. Alternatively, provide some documentation on how to decode/encode them with the existing library.
NB, the console support page says “The encoding method is available in any Cloud Datastore client library.”
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:35 (22 by maintainers)
Top Results From Across the Web
NDB Key Class | App Engine standard environment for Python 2
An instance of the Key class represents an immutable Datastore key. This page has API reference documentation. For an overview, see NDB Entities...
Read more >convert NDB urlsafe key strings to googledatastore.Key
First, let ndb deserialize the key. ndbKey = ndb.Key(urlsafe=urlsafeKey) # Rebuild the Cloud Datastore key using the path from ndb.
Read more >Key — ndb documentation - Google Cloud
A key encapsulates the following pieces of information, which together uniquely designate a (possible) entity in Google Cloud Datastore:.
Read more >datastore - Go Packages
WritePropertyMapDeterministic allows tests to make Serializer.PropertyMap deterministic. This should be set once at the top of your tests in an init() function.
Read more >Software Packages in "jammy", Subsection python - Ubuntu
... geomet (0.2.1.post1-2) [universe]: convert GeoJSON to/from WKT/WKB ... [universe]: Example data for Variant Call Format (VCF) parser for Python ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So I did some more digging and it turns out the
Reference
protobuf in App Engine isproto1
(i.e. first generation of protobuf), so the modernproto2/proto3
tooling can’t convert it. I got very close to converting using standard tools, but some small differences in the protocols prevent it.You can definitely include the
ProtocolBuffer
module in your application (in any location):and then just define your own local
Reference
andPath
classes fromI.e. you can use these files outside of App Engine. I have done so in the gist I linked to and it works just fine.
Go to the source and you will find this:
I just copied and pasted this snippet in my code and it works now. Hope this helps.