Skip to content

Commit 8682e53

Browse files
authored
Adding datastore Key.(to|from)_legacy_urlsafe. (#3491)
* 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.
1 parent b67570f commit 8682e53

File tree

6 files changed

+702
-1
lines changed

6 files changed

+702
-1
lines changed

datastore/.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
branch = True
33

44
[report]
5+
omit =
6+
_app_engine_key_pb2.py
57
fail_under = 100
68
show_missing = True
79
exclude_lines =

datastore/.flake8

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
[flake8]
22
exclude =
3+
# Datastore includes generated code in the manual layer;
4+
# do not lint this.
5+
google/cloud/datastore/_app_engine_key_pb2.py,
6+
7+
# Standard linting exemptions.
38
__pycache__,
49
.git,
510
*.pyc,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2017 Google Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto2";
16+
17+
message Reference {
18+
required string app = 13;
19+
optional string name_space = 20;
20+
required Path path = 14;
21+
optional string database_id = 23;
22+
}
23+
24+
message Path {
25+
repeated group Element = 1 {
26+
required string type = 2;
27+
optional int64 id = 3;
28+
optional string name = 4;
29+
}
30+
}

datastore/google/cloud/datastore/_app_engine_key_pb2.py

Lines changed: 184 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)