Uh oh!
There was an error while loading. Please reload this page.
Adding datastore Key.(to|from)_legacy_urlsafe. - #3491
Conversation
…cy_urlsafe. Needs more tests but wanted to get the PR in front of reviewers ASAP.
| @@ -0,0 +1,16 @@ | |||
| syntax = "proto2"; | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| 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.
Uh oh!
There was an error while loading. Please reload this page.
| ``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.
Uh oh!
There was an error while loading. Please reload this page.
| :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.
Uh oh!
There was an error while loading. Please reload this page.
| :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.
Uh oh!
There was an error while loading. Please reload this page.
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
dhermes
commented
Jun 8, 2017
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? |
* 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.
* 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.
* 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.
* 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.
Fixes#3293.
@lukesneeringer, I'll let @jonparrott describe why this is useful to add.
/cc @pcostell