Skip to content

Conversation

@michaelenglo
Copy link

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.

@googlebot
Copy link

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.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label Jun 28, 2017
)
raw_bytes = reference.SerializeToString()
return base64.urlsafe_b64encode(raw_bytes)
return base64.urlsafe_b64encode(raw_bytes).strip('=')

This comment was marked as spam.

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.

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.

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.


mod = len(urlsafe) % 4
if mod:
urlsafe += '=' * (4 - mod)

This comment was marked as spam.

@dhermes
Copy link
Contributor

dhermes commented Jun 28, 2017

Thanks for sending @michaelenglo. Please be sure to sign the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants