Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d8fa5de

Browse files
committed
Pushing release 1.0.12 (release for 1.9.21 SDK).
1 parent b6d62e1 commit d8fa5de

15 files changed

+775
-294
lines changed

RELEASE_NOTES

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Release 1.0.12 (included in SDK 1.9.21)
2+
3+
- Improved ndb deserialization speed in keys.
4+
- Fixed Query.run_to_queue to properly handle large offsets.
5+
- Fixed issue where CompressedPropertys could not be dropped from a model.
6+
- App Engine Issue 9610: Reduced memory leaks in query iteration.
7+
8+
----------------------------------------
9+
110
Release 1.0.11 (included in SDK 1.9.8)
211

312
- Added support for more efficient query cursors.

ndb/context.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,8 @@ def transaction(self, callback, **ctx_options):
978978
tconn = datastore_rpc.TransactionalConnection(
979979
adapter=parent._conn.adapter,
980980
config=parent._conn.config,
981-
transaction=transaction)
981+
transaction=transaction,
982+
_api_version=parent._conn._api_version)
982983
tctx = parent.__class__(conn=tconn,
983984
auto_batcher_class=parent._auto_batcher_class,
984985
parent_context=parent)

ndb/context_test.py

Lines changed: 68 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
from .google_imports import apiproxy_errors
1010
from .google_imports import datastore
1111
from .google_imports import datastore_errors
12+
from .google_imports import datastore_pbs
1213
from .google_imports import datastore_rpc
1314
from .google_imports import memcache
1415
from .google_imports import taskqueue
1516
from .google_test_imports import unittest
17+
from .google_test_imports import real_unittest
1618

1719
from . import context
1820
from . import eventloop
@@ -42,15 +44,7 @@ def wrap(todo, options):
4244
super(MyAutoBatcher, self).__init__(wrap, limit)
4345

4446

45-
class ContextTests(test_utils.NDBTest):
46-
47-
def setUp(self):
48-
super(ContextTests, self).setUp()
49-
MyAutoBatcher.reset_log()
50-
self.ctx = context.Context(
51-
conn=model.make_connection(default_model=model.Expando),
52-
auto_batcher_class=MyAutoBatcher)
53-
tasklets.set_context(self.ctx)
47+
class ContextTestMixin(object):
5448

5549
the_module = context
5650

@@ -98,6 +92,9 @@ def create_entities(self):
9892
key3 = yield fut3
9993
raise tasklets.Return([key1, key2, key3])
10094

95+
def make_bad_transaction(*arg, **kwargs):
96+
raise NotImplementedError
97+
10198
def testContext_AutoBatcher_Put(self):
10299
keys = self.create_entities().get_result()
103100
self.assertEqual(len(keys), 3)
@@ -752,15 +749,14 @@ def testContext_TransactionRollbackException(self):
752749

753750
class CustomException(Exception):
754751
pass
755-
def bad_transaction(*arg, **kwargs):
756-
return datastore_rpc.datastore_pb.Transaction()
757752
@tasklets.tasklet
758753
def foo():
759754
ent = model.Expando(key=key, bar=1)
760755
@tasklets.tasklet
761756
def callback():
762757
# Cause rollback to return an exception
763-
tasklets.get_context()._conn._end_transaction = bad_transaction
758+
ctx = tasklets.get_context()
759+
ctx._conn._end_transaction = self.make_bad_transaction
764760
yield ent.put_async()
765761
raise CustomException()
766762
yield self.ctx.transaction(callback)
@@ -786,25 +782,6 @@ def callback():
786782
yield self.ctx.transaction(callback)
787783
foo().check_success()
788784

789-
def testContext_TransactionXG(self):
790-
self.ExpectWarnings()
791-
# The XG option only works on the HRD datastore
792-
self.HRTest()
793-
794-
key1 = model.Key('Foo', 1)
795-
key2 = model.Key('Foo', 2)
796-
@tasklets.tasklet
797-
def tx():
798-
ctx = tasklets.get_context()
799-
ent1 = model.Expando(key=key1, foo=1)
800-
ent2 = model.Expando(key=key2, bar=2)
801-
yield ctx.put(ent1), ctx.put(ent2)
802-
raise tasklets.Return(42)
803-
self.assertRaises(datastore_errors.BadRequestError,
804-
self.ctx.transaction(tx).check_success)
805-
res = self.ctx.transaction(tx, xg=True).get_result()
806-
self.assertEqual(res, 42)
807-
808785
def testContext_TransactionMemcache(self):
809786
class Foo(model.Model):
810787
name = model.StringProperty()
@@ -1459,6 +1436,66 @@ class EmptyModel(model.Model):
14591436
self.assertTrue(e1 is e2)
14601437

14611438

1439+
class ContextV3Tests(ContextTestMixin, test_utils.NDBTest):
1440+
"""Context tests that use a Datastore V3 connection."""
1441+
1442+
def setUp(self):
1443+
super(ContextV3Tests, self).setUp()
1444+
MyAutoBatcher.reset_log()
1445+
self.ctx = context.Context(
1446+
conn=model.make_connection(default_model=model.Expando),
1447+
auto_batcher_class=MyAutoBatcher)
1448+
tasklets.set_context(self.ctx)
1449+
1450+
def make_bad_transaction(*arg, **kwargs):
1451+
return datastore_rpc.datastore_pb.Transaction()
1452+
1453+
def testContext_TransactionAddTask(self):
1454+
self.ExpectWarnings()
1455+
key = model.Key('Foo', 1)
1456+
@tasklets.tasklet
1457+
def foo():
1458+
ent = model.Expando(key=key, bar=1)
1459+
@tasklets.tasklet
1460+
def callback():
1461+
ctx = tasklets.get_context()
1462+
yield ctx.put(ent)
1463+
taskqueue.add(url='/', transactional=True)
1464+
yield self.ctx.transaction(callback)
1465+
foo().check_success()
1466+
1467+
@real_unittest.skipUnless(datastore_pbs._CLOUD_DATASTORE_ENABLED,
1468+
"V1 must be supported to run V1 tests.")
1469+
class ContextV1Tests(ContextTestMixin, test_utils.NDBCloudDatastoreV1Test):
1470+
"""Context tests that use a Cloud Datastore V1 connection."""
1471+
1472+
def setUp(self):
1473+
super(ContextV1Tests, self).setUp()
1474+
self.HRTest()
1475+
MyAutoBatcher.reset_log()
1476+
self.ctx = context.Context(
1477+
conn=model.make_connection(default_model=model.Expando,
1478+
_api_version=datastore_rpc._CLOUD_DATASTORE_V1),
1479+
auto_batcher_class=MyAutoBatcher)
1480+
tasklets.set_context(self.ctx)
1481+
1482+
def make_bad_transaction(*arg, **kwargs):
1483+
return ''
1484+
1485+
def testContext_TransactionAddTask(self):
1486+
self.ExpectWarnings()
1487+
key = model.Key('Foo', 1)
1488+
@tasklets.tasklet
1489+
def foo():
1490+
ent = model.Expando(key=key, bar=1)
1491+
@tasklets.tasklet
1492+
def callback():
1493+
ctx = tasklets.get_context()
1494+
yield ctx.put(ent)
1495+
taskqueue.add(url='/', transactional=True)
1496+
yield self.ctx.transaction(callback)
1497+
self.assertRaises(ValueError, foo().check_success)
1498+
14621499
class ContextFutureCachingTests(test_utils.NDBTest):
14631500
# See issue 62. http://goo.gl/5zLkK
14641501

ndb/google_imports.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from google.appengine.api import urlfetch
2626
from google.appengine.api import users
2727
from google.appengine.api.prospective_search import prospective_search_pb
28+
from google.appengine.datastore import datastore_pbs
2829
from google.appengine.datastore import datastore_query
2930
from google.appengine.datastore import datastore_rpc
3031
# This line will fail miserably for any app using auto_import_fixer
@@ -48,6 +49,7 @@
4849
from google3.apphosting.api import taskqueue
4950
from google3.apphosting.api import urlfetch
5051
from google3.apphosting.api import users
52+
from google3.apphosting.datastore import datastore_pbs
5153
from google3.apphosting.datastore import datastore_query
5254
from google3.apphosting.datastore import datastore_rpc
5355
from google3.storage.onestore.v3 import entity_pb

ndb/google_test_imports.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@
1919
from google3.apphosting.datastore import datastore_stub_util
2020
from google3.apphosting.ext import testbed
2121
from google3.testing.pybase import googletest as unittest
22+
23+
import unittest as real_unittest

0 commit comments

Comments
 (0)