-
Notifications
You must be signed in to change notification settings - Fork 1.6k
stripping of padding characters from datastore's urlsafe key #3559
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
Conversation
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
| ) | ||
| raw_bytes = reference.SerializeToString() | ||
| return base64.urlsafe_b64encode(raw_bytes) | ||
| return base64.urlsafe_b64encode(raw_bytes).strip('=') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| argument to ``ndb.Key(urlsafe=...)``. | ||
| argument to ``ndb.Key(urlsafe=...)``. Notice that the datastore's | ||
| version of urlsafe encoding does not have padding characters, unlike | ||
| the out of the box urlsafe_b64encode's generated urlsafe. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| datastore "Key" used within Google App Engine (a so-called | ||
| "Reference"). This assumes that ``urlsafe`` was created within an App | ||
| Engine app via something like ``ndb.Key(...).urlsafe()``. | ||
| Engine app via something like ``ndb.Key(...).urlsafe()``.Notice that |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| if not isinstance(urlsafe, basestring): | ||
| raise TypeError('urlsafe must be a string; received %r' % urlsafe) | ||
| if isinstance(urlsafe, unicode): | ||
| urlsafe = urlsafe.encode('utf8') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| mod = len(urlsafe) % 4 | ||
| if mod: | ||
| urlsafe += '=' * (4 - mod) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Thanks for sending @michaelenglo. Please be sure to sign the CLA. |
Hi,
I am proposing a change to the Google Cloud Platform Datastore's Python client library, specifically the Key module. @dhermes and I have discussed about removing the padding characters ("=") from regular b64encoded urlsafe to match the version that is used in Datastore (which does not have the padding character "="). This is done to ensure consistency in using and reproducing Datastore's convention for urlsafe key.
Please let me know if there is any other steps I may not have included and are needed to do to improve the changes.