feat: Key.to_legacy_urlsafe() - #348
Conversation
|
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
|
Hi @chmoder ! See note from Googlebot above. I cherry picked your commit. Thanks! |
|
@googlebot I consent. |
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
Thank you for your help, @chmoder! |
| raw_bytes = self.serialized() | ||
| return base64.urlsafe_b64encode(raw_bytes).strip(b"=") | ||
|
|
||
| def to_legacy_urlsafe(self, location_prefix=None): |
There was a problem hiding this comment.
If this method has no use except to add the location prefix, we can make the location prefix non-optional.
| return base64.urlsafe_b64encode(raw_bytes).strip(b"=") | ||
|
|
||
| def to_legacy_urlsafe(self, location_prefix=None): | ||
| """A ``Reference`` protobuf serialized and encoded as urlsafe base 64. |
There was a problem hiding this comment.
Docstring suggestion:
"""A urlsafe serialized ``Reference`` protobuf with an App Engine prefix
This will produce a urlsafe string which includes an App Engine location prefix ("partition"), compatible with the Google Datastore admin console.
Arguments:
location_prefix (str): A location prefix ("partition") to be prepended to the key's `project` when serializing the key. A typical value is "s~", but "e~" or other partitions are possible depending on the project's region and other factors.
|
@andrewsg Changes pushed. |
Workaround the fact that Google has deprecated the location prefix, but it is still required by the Google Datastore admin console, by allowing users to manually provide a location prefix when generating urlsafe keys.
Fixes #264.