Adding datastore Key.(to|from)_legacy_urlsafe.#3491
Merged
Conversation
…cy_urlsafe. Needs more tests but wanted to get the PR in front of reviewers ASAP.
pcostell
reviewed
Jun 8, 2017
| @@ -0,0 +1,16 @@ | |||
| syntax = "proto2"; | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
theacodes
reviewed
Jun 8, 2017
|
|
||
| This is intended to work with the "legacy" representation of a datastore | ||
| "Key" used within Google App Engine (a so-called "Reference"). This is | ||
| intended as a drop in for the value returned when using |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| ``ndb.Key(...).urlsafe()``. | ||
|
|
||
| :rtype: bytes | ||
| :returns: ASCII bytes contain the key encoded as URL-safe base64. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| :returns: The value that was decoded. | ||
| """ | ||
| # This is 3-4x faster than urlsafe_b64decode() | ||
| return base64.b64decode( |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| :rtype: str | ||
| :returns: The cleaned value. | ||
| """ | ||
| if app_str.startswith('s~') or app_str.startswith('e~'): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Also resolved some lint issues (line too long) and restructed unit test to be able to re-use "stored" values.
In particular: - Just splitting on ~ when cleaning app strings - Rewording to_legacy_urlsafe() docstring to invoke `ndb.Key(urlsafe=...)` and to restate the "returns" text - Removing the _urlsafe_b64(decode|encode) micro-optimizations that were brought over from the ndb codebase
theacodes
approved these changes
Jun 8, 2017
Contributor
Author
|
I've got LGTM here from @jonparrott and from @lukesneeringer over Hangouts, so I'm going to merge. @pcostell I'm happy to address any other concerns in a follow up PR. In particular, maybe you want me to add some kind of warning or note to the docstrings of these methods? |
landrito
pushed a commit
to landrito/google-cloud-python
that referenced
this pull request
Aug 21, 2017
* Adding bare-minimum proto for converting legacy App Engine "Reference" pbs. * Rough draft of working implementation of datastore Key.(to|from)_legacy_urlsafe. Needs more tests but wanted to get the PR in front of reviewers ASAP. * Adding implementation for datastore Key.to_legacy_urlsafe(). Also resolved some lint issues (line too long) and restructured unit test to be able to re-use "stored" values. * Adding _onestore_v3_pb2 to ignored files for flake8. * Addressing @jonparrott feedback. In particular: - Just splitting on ~ when cleaning app strings - Rewording to_legacy_urlsafe() docstring to invoke `ndb.Key(urlsafe=...)` and to restate the "returns" text - Removing the _urlsafe_b64(decode|encode) micro-optimizations that were brought over from the ndb codebase * Adding test coverage for helpers needed for Key.(to|from)_legacy_urlsafe. * Adding LICENSE header to hand-written legacy GAE proto. * Renaming _onestore_v3.proto --> _app_engine_key.proto.
landrito
pushed a commit
to landrito/google-cloud-python
that referenced
this pull request
Aug 22, 2017
* Adding bare-minimum proto for converting legacy App Engine "Reference" pbs. * Rough draft of working implementation of datastore Key.(to|from)_legacy_urlsafe. Needs more tests but wanted to get the PR in front of reviewers ASAP. * Adding implementation for datastore Key.to_legacy_urlsafe(). Also resolved some lint issues (line too long) and restructured unit test to be able to re-use "stored" values. * Adding _onestore_v3_pb2 to ignored files for flake8. * Addressing @jonparrott feedback. In particular: - Just splitting on ~ when cleaning app strings - Rewording to_legacy_urlsafe() docstring to invoke `ndb.Key(urlsafe=...)` and to restate the "returns" text - Removing the _urlsafe_b64(decode|encode) micro-optimizations that were brought over from the ndb codebase * Adding test coverage for helpers needed for Key.(to|from)_legacy_urlsafe. * Adding LICENSE header to hand-written legacy GAE proto. * Renaming _onestore_v3.proto --> _app_engine_key.proto.
landrito
pushed a commit
to landrito/google-cloud-python
that referenced
this pull request
Aug 22, 2017
* Adding bare-minimum proto for converting legacy App Engine "Reference" pbs. * Rough draft of working implementation of datastore Key.(to|from)_legacy_urlsafe. Needs more tests but wanted to get the PR in front of reviewers ASAP. * Adding implementation for datastore Key.to_legacy_urlsafe(). Also resolved some lint issues (line too long) and restructured unit test to be able to re-use "stored" values. * Adding _onestore_v3_pb2 to ignored files for flake8. * Addressing @jonparrott feedback. In particular: - Just splitting on ~ when cleaning app strings - Rewording to_legacy_urlsafe() docstring to invoke `ndb.Key(urlsafe=...)` and to restate the "returns" text - Removing the _urlsafe_b64(decode|encode) micro-optimizations that were brought over from the ndb codebase * Adding test coverage for helpers needed for Key.(to|from)_legacy_urlsafe. * Adding LICENSE header to hand-written legacy GAE proto. * Renaming _onestore_v3.proto --> _app_engine_key.proto.
parthea
pushed a commit
that referenced
this pull request
Nov 24, 2025
* Adding bare-minimum proto for converting legacy App Engine "Reference" pbs. * Rough draft of working implementation of datastore Key.(to|from)_legacy_urlsafe. Needs more tests but wanted to get the PR in front of reviewers ASAP. * Adding implementation for datastore Key.to_legacy_urlsafe(). Also resolved some lint issues (line too long) and restructured unit test to be able to re-use "stored" values. * Adding _onestore_v3_pb2 to ignored files for flake8. * Addressing @jonparrott feedback. In particular: - Just splitting on ~ when cleaning app strings - Rewording to_legacy_urlsafe() docstring to invoke `ndb.Key(urlsafe=...)` and to restate the "returns" text - Removing the _urlsafe_b64(decode|encode) micro-optimizations that were brought over from the ndb codebase * Adding test coverage for helpers needed for Key.(to|from)_legacy_urlsafe. * Adding LICENSE header to hand-written legacy GAE proto. * Renaming _onestore_v3.proto --> _app_engine_key.proto.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3293.
@lukesneeringer, I'll let @jonparrott describe why this is useful to add.
/cc @pcostell