-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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! |
google/cloud/ndb/key.py
Outdated
@@ -739,6 +739,29 @@ def urlsafe(self): | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this method has no use except to add the location prefix, we can make the location prefix non-optional.
google/cloud/ndb/key.py
Outdated
@@ -739,6 +739,29 @@ def urlsafe(self): | |||
raw_bytes = self.serialized() | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
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.