summaryrefslogtreecommitdiffstats
path: root/google-appengine/google/appengine/api/datastore_file_stub.py
diff options
context:
space:
mode:
Diffstat (limited to 'google-appengine/google/appengine/api/datastore_file_stub.py')
-rwxr-xr-xgoogle-appengine/google/appengine/api/datastore_file_stub.py44
1 files changed, 29 insertions, 15 deletions
diff --git a/google-appengine/google/appengine/api/datastore_file_stub.py b/google-appengine/google/appengine/api/datastore_file_stub.py
index 611624b..f0a809b 100755
--- a/google-appengine/google/appengine/api/datastore_file_stub.py
+++ b/google-appengine/google/appengine/api/datastore_file_stub.py
@@ -162,7 +162,7 @@ class _Cursor(object):
offset += query.offset()
if offset > 0:
- self.__last_result = results[offset - 1]
+ self.__last_result = results[min(len(results), offset) - 1]
else:
self.__last_result = cursor_entity
@@ -208,7 +208,7 @@ class _Cursor(object):
while lo < hi:
mid = (lo + hi) // 2
if compare(results[mid], cursor_entity) < 0:
- lo = mid + 1
+ lo = mid + 1
else:
hi = mid
else:
@@ -313,8 +313,6 @@ class _Cursor(object):
self.__last_result.ToPb().Encode()))
position.set_start_key(str(start_key))
position.set_start_inclusive(False)
- elif self.__query.has_compiled_cursor:
- compiled_cursor.CopyFrom(self.__query.compiled_cursor())
def PopulateQueryResult(self, result, count, compile=False):
"""Populates a QueryResult with this cursor and the given number of results.
@@ -342,7 +340,8 @@ class _Cursor(object):
result.set_more_results(self.__offset < self.count)
if compile:
- self._EncodeCompiledCursor(self.__query, result.mutable_compiled_cursor())
+ self._EncodeCompiledCursor(
+ self.__query, result.mutable_compiled_cursor())
class DatastoreFileStub(apiproxy_stub.APIProxyStub):
@@ -1063,18 +1062,30 @@ class DatastoreFileStub(apiproxy_stub.APIProxyStub):
self.__tx_snapshot = dict(snapshot)
self.__tx_actions = []
- def _Dynamic_AddAction(self, request, void):
- self.__ValidateTransaction(request.transaction())
+ def _Dynamic_AddActions(self, request, _):
+ """Associates the creation of one or more tasks with a transaction.
+
+ Args:
+ request: A taskqueue_service_pb.TaskQueueBulkAddRequest containing the
+ tasks that should be created when the transaction is comitted.
+ """
+
- if len(self.__tx_actions) >= _MAX_ACTIONS_PER_TXN:
+ if ((len(self.__tx_actions) + request.add_request_size()) >
+ _MAX_ACTIONS_PER_TXN):
raise apiproxy_errors.ApplicationError(
datastore_pb.Error.BAD_REQUEST,
'Too many messages, maximum allowed %s' % _MAX_ACTIONS_PER_TXN)
- clone = taskqueue_service_pb.TaskQueueAddRequest()
- clone.CopyFrom(request)
- clone.clear_transaction()
- self.__tx_actions.append(clone)
+ new_actions = []
+ for add_request in request.add_request_list():
+ self.__ValidateTransaction(add_request.transaction())
+ clone = taskqueue_service_pb.TaskQueueAddRequest()
+ clone.CopyFrom(add_request)
+ clone.clear_transaction()
+ new_actions.append(clone)
+
+ self.__tx_actions.extend(new_actions)
def _Dynamic_Commit(self, transaction, transaction_response):
self.__ValidateTransaction(transaction)
@@ -1108,15 +1119,18 @@ class DatastoreFileStub(apiproxy_stub.APIProxyStub):
app_str = req.app()
self.__ValidateAppId(app_str)
+ namespace_str = req.name_space()
+ app_namespace_str = datastore_types.EncodeAppIdNamespace(app_str,
+ namespace_str)
kinds = []
- for app, kind in self.__entities:
- if (app != app_str or
+ for app_namespace, kind in self.__entities:
+ if (app_namespace != app_namespace_str or
(req.has_start_kind() and kind < req.start_kind()) or
(req.has_end_kind() and kind > req.end_kind())):
continue
- app_kind = (app, kind)
+ app_kind = (app_namespace_str, kind)
if app_kind in self.__schema_cache:
kinds.append(self.__schema_cache[app_kind])
continue