google-cloud-ndb 2.5.0__tar.gz → 2.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {google_cloud_ndb-2.5.0/google_cloud_ndb.egg-info → google_cloud_ndb-2.6.0}/PKG-INFO +4 -4
- google_cloud_ndb-2.6.0/google/cloud/ndb/__init__.py +249 -0
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/_cache.py +1 -3
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/_datastore_api.py +20 -16
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/_datastore_query.py +3 -8
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/_datastore_types.py +4 -4
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/_gql.py +1 -4
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/_legacy_protocol_buffer.py +0 -1
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/_options.py +3 -4
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/_remote.py +2 -1
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/_retry.py +3 -3
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/_transaction.py +4 -6
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/blobstore.py +1 -5
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/client.py +4 -7
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/context.py +1 -2
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/django_middleware.py +0 -1
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/exceptions.py +0 -1
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/key.py +8 -15
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/metadata.py +1 -3
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/model.py +41 -32
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/msgprop.py +0 -1
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/polymodel.py +0 -1
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/query.py +22 -22
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/stats.py +0 -1
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/tasklets.py +3 -5
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/utils.py +0 -1
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/version.py +1 -1
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0/google_cloud_ndb.egg-info}/PKG-INFO +4 -4
- google_cloud_ndb-2.6.0/google_cloud_ndb.egg-info/requires.txt +6 -0
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/setup.py +7 -7
- google_cloud_ndb-2.5.0/google/cloud/ndb/__init__.py +0 -239
- google_cloud_ndb-2.5.0/google_cloud_ndb.egg-info/requires.txt +0 -6
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/AUTHORS +0 -0
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/LICENSE +0 -0
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/README.md +0 -0
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/_batch.py +0 -0
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/_eventloop.py +3 -3
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/_legacy_entity_pb.py +0 -0
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google/cloud/ndb/global_cache.py +3 -3
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google_cloud_ndb.egg-info/SOURCES.txt +0 -0
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google_cloud_ndb.egg-info/dependency_links.txt +0 -0
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google_cloud_ndb.egg-info/not-zip-safe +0 -0
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/google_cloud_ndb.egg-info/top_level.txt +0 -0
- {google_cloud_ndb-2.5.0 → google_cloud_ndb-2.6.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: google-cloud-ndb
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.6.0
|
|
4
4
|
Summary: NDB library for Google Cloud Datastore
|
|
5
5
|
Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-ndb
|
|
6
6
|
Author: Google LLC
|
|
@@ -25,9 +25,9 @@ Requires-Python: >=3.10
|
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
License-File: LICENSE
|
|
27
27
|
License-File: AUTHORS
|
|
28
|
-
Requires-Dist: google-api-core[grpc]<3.0.0,>=2.
|
|
29
|
-
Requires-Dist: google-cloud-datastore
|
|
30
|
-
Requires-Dist: protobuf<8.0.0,>=
|
|
28
|
+
Requires-Dist: google-api-core[grpc]<3.0.0,>=2.28.0
|
|
29
|
+
Requires-Dist: google-cloud-datastore<3.0.0,>=2.21.0
|
|
30
|
+
Requires-Dist: protobuf<8.0.0,>=6.33.5
|
|
31
31
|
Requires-Dist: pymemcache<5.0.0,>=2.1.0
|
|
32
32
|
Requires-Dist: pytz>=2022.1
|
|
33
33
|
Requires-Dist: redis<8.0.0,>=3.0.0
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# Copyright 2018 Google LLC
|
|
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
|
+
# https://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
|
+
"""``ndb`` is a library for Google Cloud Firestore in Datastore Mode and Google Cloud Datastore.
|
|
16
|
+
|
|
17
|
+
It was originally included in the Google App Engine runtime as a "new"
|
|
18
|
+
version of the ``db`` API (hence ``ndb``).
|
|
19
|
+
|
|
20
|
+
.. autodata:: __version__
|
|
21
|
+
.. autodata:: __all__
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
import google.api_core as api_core
|
|
25
|
+
|
|
26
|
+
from google.cloud.ndb import version
|
|
27
|
+
|
|
28
|
+
__version__: str = version.__version__
|
|
29
|
+
|
|
30
|
+
from google.cloud.ndb._datastore_api import EVENTUAL, EVENTUAL_CONSISTENCY, STRONG
|
|
31
|
+
from google.cloud.ndb._datastore_query import Cursor, QueryIterator
|
|
32
|
+
from google.cloud.ndb._transaction import (
|
|
33
|
+
in_transaction,
|
|
34
|
+
non_transactional,
|
|
35
|
+
transaction,
|
|
36
|
+
transaction_async,
|
|
37
|
+
transactional,
|
|
38
|
+
transactional_async,
|
|
39
|
+
transactional_tasklet,
|
|
40
|
+
)
|
|
41
|
+
from google.cloud.ndb.client import Client
|
|
42
|
+
from google.cloud.ndb.context import (
|
|
43
|
+
AutoBatcher,
|
|
44
|
+
Context,
|
|
45
|
+
ContextOptions,
|
|
46
|
+
TransactionOptions,
|
|
47
|
+
get_context,
|
|
48
|
+
get_toplevel_context,
|
|
49
|
+
)
|
|
50
|
+
from google.cloud.ndb.global_cache import GlobalCache, MemcacheCache, RedisCache
|
|
51
|
+
from google.cloud.ndb.key import Key
|
|
52
|
+
from google.cloud.ndb.model import (
|
|
53
|
+
BadProjectionError,
|
|
54
|
+
BlobKey,
|
|
55
|
+
BlobKeyProperty,
|
|
56
|
+
BlobProperty,
|
|
57
|
+
BooleanProperty,
|
|
58
|
+
ComputedProperty,
|
|
59
|
+
ComputedPropertyError,
|
|
60
|
+
DateProperty,
|
|
61
|
+
DateTimeProperty,
|
|
62
|
+
Expando,
|
|
63
|
+
FloatProperty,
|
|
64
|
+
GenericProperty,
|
|
65
|
+
GeoPt,
|
|
66
|
+
GeoPtProperty,
|
|
67
|
+
Index,
|
|
68
|
+
IndexProperty,
|
|
69
|
+
IndexState,
|
|
70
|
+
IntegerProperty,
|
|
71
|
+
InvalidPropertyError,
|
|
72
|
+
JsonProperty,
|
|
73
|
+
KeyProperty,
|
|
74
|
+
KindError,
|
|
75
|
+
LocalStructuredProperty,
|
|
76
|
+
MetaModel,
|
|
77
|
+
Model,
|
|
78
|
+
ModelAdapter,
|
|
79
|
+
ModelAttribute,
|
|
80
|
+
ModelKey,
|
|
81
|
+
PickleProperty,
|
|
82
|
+
Property,
|
|
83
|
+
ReadonlyPropertyError,
|
|
84
|
+
Rollback,
|
|
85
|
+
StringProperty,
|
|
86
|
+
StructuredProperty,
|
|
87
|
+
TextProperty,
|
|
88
|
+
TimeProperty,
|
|
89
|
+
UnprojectedPropertyError,
|
|
90
|
+
User,
|
|
91
|
+
UserNotFoundError,
|
|
92
|
+
UserProperty,
|
|
93
|
+
delete_multi,
|
|
94
|
+
delete_multi_async,
|
|
95
|
+
get_indexes,
|
|
96
|
+
get_indexes_async,
|
|
97
|
+
get_multi,
|
|
98
|
+
get_multi_async,
|
|
99
|
+
make_connection,
|
|
100
|
+
put_multi,
|
|
101
|
+
put_multi_async,
|
|
102
|
+
)
|
|
103
|
+
from google.cloud.ndb.polymodel import PolyModel
|
|
104
|
+
from google.cloud.ndb.query import (
|
|
105
|
+
AND,
|
|
106
|
+
OR,
|
|
107
|
+
ConjunctionNode,
|
|
108
|
+
DisjunctionNode,
|
|
109
|
+
FalseNode,
|
|
110
|
+
FilterNode,
|
|
111
|
+
Node,
|
|
112
|
+
Parameter,
|
|
113
|
+
ParameterizedFunction,
|
|
114
|
+
ParameterizedThing,
|
|
115
|
+
ParameterNode,
|
|
116
|
+
PostFilterNode,
|
|
117
|
+
Query,
|
|
118
|
+
QueryOptions,
|
|
119
|
+
RepeatedStructuredPropertyPredicate,
|
|
120
|
+
gql,
|
|
121
|
+
)
|
|
122
|
+
from google.cloud.ndb.tasklets import (
|
|
123
|
+
Future,
|
|
124
|
+
QueueFuture,
|
|
125
|
+
ReducingFuture,
|
|
126
|
+
Return,
|
|
127
|
+
SerialQueueFuture,
|
|
128
|
+
add_flow_exception,
|
|
129
|
+
make_context,
|
|
130
|
+
make_default_context,
|
|
131
|
+
set_context,
|
|
132
|
+
sleep,
|
|
133
|
+
synctasklet,
|
|
134
|
+
tasklet,
|
|
135
|
+
toplevel,
|
|
136
|
+
wait_all,
|
|
137
|
+
wait_any,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
api_core.check_python_version(__name__)
|
|
141
|
+
api_core.check_dependency_versions(__name__)
|
|
142
|
+
|
|
143
|
+
__all__ = [
|
|
144
|
+
"__version__",
|
|
145
|
+
"AutoBatcher",
|
|
146
|
+
"Client",
|
|
147
|
+
"Context",
|
|
148
|
+
"ContextOptions",
|
|
149
|
+
"EVENTUAL",
|
|
150
|
+
"EVENTUAL_CONSISTENCY",
|
|
151
|
+
"STRONG",
|
|
152
|
+
"TransactionOptions",
|
|
153
|
+
"Key",
|
|
154
|
+
"BlobKey",
|
|
155
|
+
"BlobKeyProperty",
|
|
156
|
+
"BlobProperty",
|
|
157
|
+
"BooleanProperty",
|
|
158
|
+
"ComputedProperty",
|
|
159
|
+
"ComputedPropertyError",
|
|
160
|
+
"DateProperty",
|
|
161
|
+
"DateTimeProperty",
|
|
162
|
+
"delete_multi",
|
|
163
|
+
"delete_multi_async",
|
|
164
|
+
"Expando",
|
|
165
|
+
"FloatProperty",
|
|
166
|
+
"GenericProperty",
|
|
167
|
+
"GeoPt",
|
|
168
|
+
"GeoPtProperty",
|
|
169
|
+
"get_indexes",
|
|
170
|
+
"get_indexes_async",
|
|
171
|
+
"get_multi",
|
|
172
|
+
"get_multi_async",
|
|
173
|
+
"GlobalCache",
|
|
174
|
+
"in_transaction",
|
|
175
|
+
"Index",
|
|
176
|
+
"IndexProperty",
|
|
177
|
+
"IndexState",
|
|
178
|
+
"IntegerProperty",
|
|
179
|
+
"InvalidPropertyError",
|
|
180
|
+
"BadProjectionError",
|
|
181
|
+
"JsonProperty",
|
|
182
|
+
"KeyProperty",
|
|
183
|
+
"KindError",
|
|
184
|
+
"LocalStructuredProperty",
|
|
185
|
+
"make_connection",
|
|
186
|
+
"MemcacheCache",
|
|
187
|
+
"MetaModel",
|
|
188
|
+
"Model",
|
|
189
|
+
"ModelAdapter",
|
|
190
|
+
"ModelAttribute",
|
|
191
|
+
"ModelKey",
|
|
192
|
+
"non_transactional",
|
|
193
|
+
"PickleProperty",
|
|
194
|
+
"PolyModel",
|
|
195
|
+
"Property",
|
|
196
|
+
"put_multi",
|
|
197
|
+
"put_multi_async",
|
|
198
|
+
"ReadonlyPropertyError",
|
|
199
|
+
"RedisCache",
|
|
200
|
+
"Rollback",
|
|
201
|
+
"StringProperty",
|
|
202
|
+
"StructuredProperty",
|
|
203
|
+
"TextProperty",
|
|
204
|
+
"TimeProperty",
|
|
205
|
+
"transaction",
|
|
206
|
+
"transaction_async",
|
|
207
|
+
"transactional",
|
|
208
|
+
"transactional_async",
|
|
209
|
+
"transactional_tasklet",
|
|
210
|
+
"UnprojectedPropertyError",
|
|
211
|
+
"User",
|
|
212
|
+
"UserNotFoundError",
|
|
213
|
+
"UserProperty",
|
|
214
|
+
"ConjunctionNode",
|
|
215
|
+
"AND",
|
|
216
|
+
"Cursor",
|
|
217
|
+
"DisjunctionNode",
|
|
218
|
+
"OR",
|
|
219
|
+
"FalseNode",
|
|
220
|
+
"FilterNode",
|
|
221
|
+
"gql",
|
|
222
|
+
"Node",
|
|
223
|
+
"Parameter",
|
|
224
|
+
"ParameterizedFunction",
|
|
225
|
+
"ParameterizedThing",
|
|
226
|
+
"ParameterNode",
|
|
227
|
+
"PostFilterNode",
|
|
228
|
+
"Query",
|
|
229
|
+
"QueryIterator",
|
|
230
|
+
"QueryOptions",
|
|
231
|
+
"RepeatedStructuredPropertyPredicate",
|
|
232
|
+
"add_flow_exception",
|
|
233
|
+
"Future",
|
|
234
|
+
"get_context",
|
|
235
|
+
"get_toplevel_context",
|
|
236
|
+
"make_context",
|
|
237
|
+
"make_default_context",
|
|
238
|
+
"QueueFuture",
|
|
239
|
+
"ReducingFuture",
|
|
240
|
+
"Return",
|
|
241
|
+
"SerialQueueFuture",
|
|
242
|
+
"set_context",
|
|
243
|
+
"sleep",
|
|
244
|
+
"synctasklet",
|
|
245
|
+
"tasklet",
|
|
246
|
+
"toplevel",
|
|
247
|
+
"wait_all",
|
|
248
|
+
"wait_any",
|
|
249
|
+
]
|
|
@@ -20,10 +20,8 @@ import warnings
|
|
|
20
20
|
|
|
21
21
|
from google.api_core import retry as core_retry
|
|
22
22
|
|
|
23
|
-
from google.cloud.ndb import _batch
|
|
23
|
+
from google.cloud.ndb import _batch, tasklets, utils
|
|
24
24
|
from google.cloud.ndb import context as context_module
|
|
25
|
-
from google.cloud.ndb import tasklets
|
|
26
|
-
from google.cloud.ndb import utils
|
|
27
25
|
|
|
28
26
|
_LOCKED_FOR_READ = b"0-"
|
|
29
27
|
_LOCKED_FOR_WRITE = b"00"
|
|
@@ -14,25 +14,27 @@
|
|
|
14
14
|
|
|
15
15
|
"""Functions that interact with Datastore backend."""
|
|
16
16
|
|
|
17
|
-
import grpc
|
|
18
17
|
import itertools
|
|
19
18
|
import logging
|
|
20
19
|
|
|
20
|
+
import grpc
|
|
21
21
|
from google.api_core import exceptions as core_exceptions
|
|
22
22
|
from google.api_core import gapic_v1
|
|
23
23
|
from google.cloud.datastore import helpers
|
|
24
24
|
from google.cloud.datastore_v1.types import datastore as datastore_pb2
|
|
25
25
|
from google.cloud.datastore_v1.types import entity as entity_pb2
|
|
26
26
|
|
|
27
|
+
from google.cloud.ndb import (
|
|
28
|
+
_batch,
|
|
29
|
+
_cache,
|
|
30
|
+
_eventloop,
|
|
31
|
+
_options,
|
|
32
|
+
_remote,
|
|
33
|
+
_retry,
|
|
34
|
+
tasklets,
|
|
35
|
+
utils,
|
|
36
|
+
)
|
|
27
37
|
from google.cloud.ndb import context as context_module
|
|
28
|
-
from google.cloud.ndb import _batch
|
|
29
|
-
from google.cloud.ndb import _cache
|
|
30
|
-
from google.cloud.ndb import _eventloop
|
|
31
|
-
from google.cloud.ndb import _options
|
|
32
|
-
from google.cloud.ndb import _remote
|
|
33
|
-
from google.cloud.ndb import _retry
|
|
34
|
-
from google.cloud.ndb import tasklets
|
|
35
|
-
from google.cloud.ndb import utils
|
|
36
38
|
|
|
37
39
|
EVENTUAL = datastore_pb2.ReadOptions.ReadConsistency.EVENTUAL
|
|
38
40
|
EVENTUAL_CONSISTENCY = EVENTUAL # Legacy NDB
|
|
@@ -432,6 +434,7 @@ def delete(key, options):
|
|
|
432
434
|
use_global_cache = context._use_global_cache(key, options)
|
|
433
435
|
use_datastore = context._use_datastore(key, options)
|
|
434
436
|
transaction = context.transaction
|
|
437
|
+
lock = None
|
|
435
438
|
|
|
436
439
|
if use_global_cache:
|
|
437
440
|
cache_key = _cache.global_cache_key(key)
|
|
@@ -448,17 +451,18 @@ def delete(key, options):
|
|
|
448
451
|
yield batch.delete(key)
|
|
449
452
|
|
|
450
453
|
if use_global_cache:
|
|
451
|
-
if
|
|
454
|
+
if lock is not None:
|
|
455
|
+
if transaction:
|
|
452
456
|
|
|
453
|
-
|
|
454
|
-
|
|
457
|
+
def callback():
|
|
458
|
+
_cache.global_unlock_for_write(cache_key, lock).result()
|
|
455
459
|
|
|
456
|
-
|
|
460
|
+
context.call_on_transaction_complete(callback)
|
|
457
461
|
|
|
458
|
-
|
|
459
|
-
|
|
462
|
+
else:
|
|
463
|
+
yield _cache.global_unlock_for_write(cache_key, lock)
|
|
460
464
|
|
|
461
|
-
|
|
465
|
+
elif not use_datastore:
|
|
462
466
|
yield _cache.global_delete(cache_key)
|
|
463
467
|
|
|
464
468
|
|
|
@@ -20,20 +20,15 @@ import functools
|
|
|
20
20
|
import logging
|
|
21
21
|
import os
|
|
22
22
|
|
|
23
|
-
from google.cloud import
|
|
24
|
-
|
|
23
|
+
from google.cloud.datastore import Key, helpers
|
|
25
24
|
from google.cloud.datastore_v1.types import datastore as datastore_pb2
|
|
26
25
|
from google.cloud.datastore_v1.types import entity as entity_pb2
|
|
27
26
|
from google.cloud.datastore_v1.types import query as query_pb2
|
|
28
|
-
from google.cloud.datastore import helpers, Key
|
|
29
27
|
|
|
28
|
+
from google.cloud import environment_vars
|
|
29
|
+
from google.cloud.ndb import _datastore_api, exceptions, model, tasklets, utils
|
|
30
30
|
from google.cloud.ndb import context as context_module
|
|
31
|
-
from google.cloud.ndb import _datastore_api
|
|
32
|
-
from google.cloud.ndb import exceptions
|
|
33
31
|
from google.cloud.ndb import key as key_module
|
|
34
|
-
from google.cloud.ndb import model
|
|
35
|
-
from google.cloud.ndb import tasklets
|
|
36
|
-
from google.cloud.ndb import utils
|
|
37
32
|
|
|
38
33
|
log = logging.getLogger(__name__)
|
|
39
34
|
|
|
@@ -24,7 +24,6 @@ import functools
|
|
|
24
24
|
|
|
25
25
|
from google.cloud.ndb import exceptions
|
|
26
26
|
|
|
27
|
-
|
|
28
27
|
_MAX_STRING_LENGTH = 1500
|
|
29
28
|
|
|
30
29
|
|
|
@@ -55,12 +54,13 @@ class BlobKey(object):
|
|
|
55
54
|
if isinstance(blob_key, bytes):
|
|
56
55
|
if len(blob_key) > _MAX_STRING_LENGTH:
|
|
57
56
|
raise exceptions.BadValueError(
|
|
58
|
-
"blob key must be under {:d}
|
|
57
|
+
"blob key must be under {:d} bytes.".format(_MAX_STRING_LENGTH)
|
|
59
58
|
)
|
|
60
59
|
elif blob_key is not None:
|
|
61
60
|
raise exceptions.BadValueError(
|
|
62
|
-
"blob key should be bytes; received "
|
|
63
|
-
|
|
61
|
+
"blob key should be bytes; received {} (a {})".format(
|
|
62
|
+
blob_key, type(blob_key).__name__
|
|
63
|
+
)
|
|
64
64
|
)
|
|
65
65
|
|
|
66
66
|
self._blob_key = blob_key
|
|
@@ -3,12 +3,9 @@ import re
|
|
|
3
3
|
import time
|
|
4
4
|
from typing import Any
|
|
5
5
|
|
|
6
|
+
from google.cloud.ndb import _datastore_query, exceptions, key, model
|
|
6
7
|
from google.cloud.ndb import context as context_module
|
|
7
|
-
from google.cloud.ndb import exceptions
|
|
8
8
|
from google.cloud.ndb import query as query_module
|
|
9
|
-
from google.cloud.ndb import key
|
|
10
|
-
from google.cloud.ndb import model
|
|
11
|
-
from google.cloud.ndb import _datastore_query
|
|
12
9
|
|
|
13
10
|
|
|
14
11
|
class GQL(object):
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
import functools
|
|
18
18
|
import itertools
|
|
19
19
|
import logging
|
|
20
|
+
from typing import Any
|
|
20
21
|
|
|
21
22
|
from google.cloud.ndb import exceptions
|
|
22
|
-
from typing import Any
|
|
23
23
|
|
|
24
24
|
log = logging.getLogger(__name__)
|
|
25
25
|
|
|
@@ -135,8 +135,7 @@ class Options(object):
|
|
|
135
135
|
global_cache_timeout = kwargs.get("global_cache_timeout")
|
|
136
136
|
if global_cache_timeout is not None:
|
|
137
137
|
raise TypeError(
|
|
138
|
-
"Can't specify both 'memcache_timeout' and "
|
|
139
|
-
"'global_cache_timeout'"
|
|
138
|
+
"Can't specify both 'memcache_timeout' and 'global_cache_timeout'"
|
|
140
139
|
)
|
|
141
140
|
kwargs["global_cache_timeout"] = memcache_timeout
|
|
142
141
|
|
|
@@ -223,7 +222,7 @@ class ReadOptions(Options):
|
|
|
223
222
|
)
|
|
224
223
|
if kwargs.get("read_consistency"):
|
|
225
224
|
raise TypeError(
|
|
226
|
-
"Cannot use both 'read_policy' and 'read_consistency'
|
|
225
|
+
"Cannot use both 'read_policy' and 'read_consistency' options."
|
|
227
226
|
)
|
|
228
227
|
kwargs["read_consistency"] = read_policy
|
|
229
228
|
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
import functools
|
|
18
18
|
import itertools
|
|
19
19
|
|
|
20
|
-
from google.api_core import retry as core_retry
|
|
21
20
|
from google.api_core import exceptions as core_exceptions
|
|
22
|
-
from google.
|
|
23
|
-
|
|
21
|
+
from google.api_core import retry as core_retry
|
|
22
|
+
|
|
23
|
+
from google.cloud.ndb import exceptions, tasklets
|
|
24
24
|
|
|
25
25
|
_DEFAULT_INITIAL_DELAY = 1.0 # seconds
|
|
26
26
|
_DEFAULT_MAXIMUM_DELAY = 60.0 # seconds
|
|
@@ -15,10 +15,7 @@
|
|
|
15
15
|
import functools
|
|
16
16
|
import logging
|
|
17
17
|
|
|
18
|
-
from google.cloud.ndb import exceptions
|
|
19
|
-
from google.cloud.ndb import _retry
|
|
20
|
-
from google.cloud.ndb import tasklets
|
|
21
|
-
from google.cloud.ndb import utils
|
|
18
|
+
from google.cloud.ndb import _retry, exceptions, tasklets, utils
|
|
22
19
|
|
|
23
20
|
log = logging.getLogger(__name__)
|
|
24
21
|
|
|
@@ -50,8 +47,9 @@ class _Propagation(object):
|
|
|
50
47
|
self.propagation = propagation
|
|
51
48
|
else:
|
|
52
49
|
raise ValueError(
|
|
53
|
-
"Unexpected value for propagation. Got: {}. Expected one of: "
|
|
54
|
-
|
|
50
|
+
"Unexpected value for propagation. Got: {}. Expected one of: {}".format(
|
|
51
|
+
propagation, propagation_options
|
|
52
|
+
)
|
|
55
53
|
)
|
|
56
54
|
|
|
57
55
|
propagation_names = context_module.TransactionOptions._INT_TO_NAME
|
|
@@ -20,11 +20,7 @@ Storage.
|
|
|
20
20
|
No longer supported.
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
from google.cloud.ndb import _datastore_types
|
|
25
|
-
from google.cloud.ndb import model
|
|
26
|
-
from google.cloud.ndb import exceptions
|
|
27
|
-
|
|
23
|
+
from google.cloud.ndb import _datastore_types, exceptions, model
|
|
28
24
|
|
|
29
25
|
__all__ = [
|
|
30
26
|
"BLOB_INFO_KIND",
|
|
@@ -15,25 +15,22 @@
|
|
|
15
15
|
"""A client for NDB which manages credentials, project, namespace, and database."""
|
|
16
16
|
|
|
17
17
|
import contextlib
|
|
18
|
-
import grpc
|
|
19
18
|
import os
|
|
20
|
-
import requests
|
|
21
19
|
|
|
22
20
|
import google.api_core.client_options
|
|
23
|
-
|
|
21
|
+
import grpc
|
|
22
|
+
import requests
|
|
24
23
|
from google.api_core.gapic_v1 import client_info
|
|
25
|
-
from google.cloud import environment_vars
|
|
26
|
-
from google.cloud import _helpers
|
|
27
|
-
from google.cloud import client as google_client
|
|
28
24
|
from google.cloud.datastore_v1.services.datastore.transports import (
|
|
29
25
|
grpc as datastore_grpc,
|
|
30
26
|
)
|
|
31
27
|
|
|
28
|
+
from google.cloud import _helpers, environment_vars
|
|
29
|
+
from google.cloud import client as google_client
|
|
32
30
|
from google.cloud.ndb import __version__
|
|
33
31
|
from google.cloud.ndb import context as context_module
|
|
34
32
|
from google.cloud.ndb import key as key_module
|
|
35
33
|
|
|
36
|
-
|
|
37
34
|
_CLIENT_INFO = client_info.ClientInfo(
|
|
38
35
|
user_agent="google-cloud-ndb/{}".format(__version__)
|
|
39
36
|
)
|
|
@@ -24,8 +24,7 @@ import threading
|
|
|
24
24
|
import uuid
|
|
25
25
|
from typing import Any, cast
|
|
26
26
|
|
|
27
|
-
from google.cloud.ndb import _eventloop
|
|
28
|
-
from google.cloud.ndb import exceptions
|
|
27
|
+
from google.cloud.ndb import _eventloop, exceptions
|
|
29
28
|
from google.cloud.ndb import key as key_module
|
|
30
29
|
|
|
31
30
|
|
|
@@ -87,19 +87,15 @@ manager is not available so the default is to have an unset or empty
|
|
|
87
87
|
namespace. To explicitly select the empty namespace pass ``namespace=""``.
|
|
88
88
|
"""
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
import typing
|
|
92
90
|
import base64
|
|
93
91
|
import functools
|
|
92
|
+
import typing
|
|
94
93
|
|
|
94
|
+
import google.cloud.datastore
|
|
95
95
|
from google.cloud.datastore import _app_engine_key_pb2
|
|
96
96
|
from google.cloud.datastore import key as _key_module
|
|
97
|
-
import google.cloud.datastore
|
|
98
97
|
|
|
99
|
-
from google.cloud.ndb import exceptions
|
|
100
|
-
from google.cloud.ndb import _options
|
|
101
|
-
from google.cloud.ndb import tasklets
|
|
102
|
-
from google.cloud.ndb import utils
|
|
98
|
+
from google.cloud.ndb import _options, exceptions, tasklets, utils
|
|
103
99
|
|
|
104
100
|
__all__ = ["Key", "UNDEFINED"]
|
|
105
101
|
_APP_ID_ENVIRONMENT = "APPLICATION_ID"
|
|
@@ -918,9 +914,8 @@ class Key(object):
|
|
|
918
914
|
:class:`~google.cloud.ndb.tasklets.Future`
|
|
919
915
|
"""
|
|
920
916
|
# Avoid circular import in Python 2.7
|
|
921
|
-
from google.cloud.ndb import model
|
|
917
|
+
from google.cloud.ndb import _datastore_api, model
|
|
922
918
|
from google.cloud.ndb import context as context_module
|
|
923
|
-
from google.cloud.ndb import _datastore_api
|
|
924
919
|
|
|
925
920
|
cls = model.Model._kind_map.get(self.kind())
|
|
926
921
|
|
|
@@ -1054,9 +1049,8 @@ class Key(object):
|
|
|
1054
1049
|
force_writes (bool): No longer supported.
|
|
1055
1050
|
"""
|
|
1056
1051
|
# Avoid circular import in Python 2.7
|
|
1057
|
-
from google.cloud.ndb import model
|
|
1052
|
+
from google.cloud.ndb import _datastore_api, model
|
|
1058
1053
|
from google.cloud.ndb import context as context_module
|
|
1059
|
-
from google.cloud.ndb import _datastore_api
|
|
1060
1054
|
|
|
1061
1055
|
cls = model.Model._kind_map.get(self.kind())
|
|
1062
1056
|
if cls:
|
|
@@ -1317,7 +1311,7 @@ def _parse_from_ref(
|
|
|
1317
1311
|
app=None,
|
|
1318
1312
|
namespace=None,
|
|
1319
1313
|
database: typing.Optional[str] = None,
|
|
1320
|
-
**kwargs
|
|
1314
|
+
**kwargs,
|
|
1321
1315
|
):
|
|
1322
1316
|
"""Construct a key from a Reference.
|
|
1323
1317
|
|
|
@@ -1361,7 +1355,7 @@ def _parse_from_ref(
|
|
|
1361
1355
|
|
|
1362
1356
|
if kwargs or not _exactly_one_specified(reference, serialized, urlsafe):
|
|
1363
1357
|
raise TypeError(
|
|
1364
|
-
"Cannot construct Key reference from incompatible
|
|
1358
|
+
"Cannot construct Key reference from incompatible keyword arguments."
|
|
1365
1359
|
)
|
|
1366
1360
|
|
|
1367
1361
|
if reference:
|
|
@@ -1528,8 +1522,7 @@ def _clean_flat_path(flat):
|
|
|
1528
1522
|
flat[i] = kind
|
|
1529
1523
|
if not isinstance(kind, str):
|
|
1530
1524
|
raise TypeError(
|
|
1531
|
-
"Key kind must be a string or Model class; "
|
|
1532
|
-
"received {!r}".format(kind)
|
|
1525
|
+
"Key kind must be a string or Model class; received {!r}".format(kind)
|
|
1533
1526
|
)
|
|
1534
1527
|
# Make sure the ``id_`` is either a string or int. In the special case
|
|
1535
1528
|
# of a partial key, ``id_`` can be ``None`` for the last pair.
|
|
@@ -38,11 +38,9 @@ A simplified API is also offered:
|
|
|
38
38
|
limit the query to a range of names, such that start <= name < end.
|
|
39
39
|
"""
|
|
40
40
|
|
|
41
|
-
from google.cloud.ndb import exceptions
|
|
42
|
-
from google.cloud.ndb import model
|
|
41
|
+
from google.cloud.ndb import exceptions, model
|
|
43
42
|
from google.cloud.ndb import query as query_module
|
|
44
43
|
|
|
45
|
-
|
|
46
44
|
__all__ = [
|
|
47
45
|
"get_entity_group_version",
|
|
48
46
|
"get_kinds",
|