GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Adding datastore Key.(to|from)_legacy_urlsafe. by dhermes · Pull Request #3491 · googleapis/google-cloud-python

Conversation

@dhermes

@dhermes dhermes commented Jun 8, 2017

Copy link
Copy Markdown
Contributor

Fixes #3293.

@lukesneeringer, I'll let @jonparrott describe why this is useful to add.

/cc @pcostell

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
dhermes added 2 commits June 8, 2017 12:46
@dhermes
Adding bare-minimum proto for converting legacy App Engine "Reference…
134ae80
…" pbs.
@dhermes
Rough draft of working implementation of datastore Key.(to|from)_lega…
72e26b7
…cy_urlsafe.

Needs more tests but wanted to get the PR in front of reviewers ASAP.
@dhermes dhermes added the api: datastore Issues related to the Datastore API. label Jun 8, 2017
@dhermes dhermes assigned lukesneeringer, tseaver and theacodes Jun 8, 2017
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 8, 2017
pcostell
pcostell reviewed Jun 8, 2017
View reviewed changes
Comment thread datastore/google/cloud/datastore/_onestore_v3.proto Outdated
@@ -0,0 +1,16 @@
syntax = "proto2";

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

theacodes
theacodes reviewed Jun 8, 2017
View reviewed changes
Comment thread datastore/google/cloud/datastore/key.py Outdated

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.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread datastore/google/cloud/datastore/key.py Outdated
``ndb.Key(...).urlsafe()``.

:rtype: bytes
:returns: ASCII bytes contain the key encoded as URL-safe base64.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread datastore/google/cloud/datastore/key.py Outdated
:returns: The value that was decoded.
"""
# This is 3-4x faster than urlsafe_b64decode()
return base64.b64decode(

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread datastore/google/cloud/datastore/key.py Outdated
:rtype: str
:returns: The cleaned value.
"""
if app_str.startswith('s~') or app_str.startswith('e~'):

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes dhermes mentioned this pull request Jun 8, 2017
Provide a method to convert ndb Key's urlsafe format to/from datastore.Key #3293
Closed
dhermes added 3 commits June 8, 2017 14:17
@dhermes
Adding implementation for datastore Key.to_legacy_urlsafe().
36d9abc
Also resolved some lint issues (line too long) and restructed
unit test to be able to re-use "stored" values.
@dhermes
Adding _onestore_v3_pb2 to ignored files for flake8.
92779fd
@dhermes
Addressing @jonparrott feedback.
22097ff
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
theacodes approved these changes Jun 8, 2017
View reviewed changes
dhermes added 3 commits June 8, 2017 14:54
@dhermes
Adding test coverage for helpers needed for Key.(to|from)_legacy_urls…
bb87e62
…afe.
@dhermes
Adding LICENSE header to hand-written legacy GAE proto.
30a84ff
@dhermes
Renaming _onestore_v3.proto --> _app_engine_key.proto.
d32361e
@dhermes

dhermes commented Jun 8, 2017

Copy link
Copy Markdown
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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes
dhermes merged commit 8682e53 into googleapis:master Jun 8, 2017
@dhermes
dhermes deleted the ds-legacy-urlsafe branch June 8, 2017 23:15
@tseaver tseaver mentioned this pull request Jun 26, 2017
Prep datastore-1.1.0 release. #3527
Merged
@michaelenglo michaelenglo mentioned this pull request Jul 10, 2017
Datastore Key's reference is missing location identifier in app argument in to_legacy_urlsafe() #3597
Closed
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 21, 2017
@dhermes @landrito
Adding datastore Key.(to|from)_legacy_urlsafe. (googleapis#3491)
5a46812
* 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
@dhermes @landrito
Adding datastore Key.(to|from)_legacy_urlsafe. (googleapis#3491)
9640a58
* 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
@dhermes @landrito
Adding datastore Key.(to|from)_legacy_urlsafe. (googleapis#3491)
e99fc55
* 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
@dhermes
Adding datastore Key.(to|from)_legacy_urlsafe. (#3491)
d020a47
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

2 more reviewers
@pcostell pcostell pcostell left review comments
@theacodes theacodes theacodes approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@lukesneeringer lukesneeringer

@tseaver tseaver

@theacodes theacodes

Labels

api: datastore Issues related to the Datastore API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@dhermes @theacodes @pcostell @lukesneeringer @tseaver @googlebot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.