Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

A few tweaks to BatchGetItem support for DynamoDB. Related to #533.

  • Loading branch information...
commit 6e47ee639b3b1398a47b7edbd97fd129d0aa18e4 1 parent 9d42dea
@garnaat garnaat authored
View
7 boto/dynamodb/batch.py
@@ -49,6 +49,10 @@ class BatchList(list):
:class:`boto.dynamodb.batch.Batch` objects.
"""
+ def __init__(self, layer2):
+ list.__init__(self)
+ self.layer2 = layer2
+
def add_batch(self, table, keys, attributes_to_get=None):
"""
Add a Batch to this BatchList.
@@ -72,5 +76,8 @@ def add_batch(self, table, keys, attributes_to_get=None):
"""
self.append(Batch(table, keys, attributes_to_get))
+ def submit(self):
+ return self.layer2.batch_get_item(self)
+
View
6 boto/dynamodb/layer2.py
@@ -229,7 +229,11 @@ def build_key_from_values(self, schema, hash_key, range_key=None):
return dynamodb_key
def new_batch_list(self):
- return BatchList()
+ """
+ Return a new, empty :class:`boto.dynamodb.batch.BatchList`
+ object.
+ """
+ return BatchList(self)
def list_tables(self, limit=None, start_table=None):
"""
View
2  tests/dynamodb/test_layer2.py
@@ -253,7 +253,7 @@ def test_layer2_basic(self):
batch_list = c.new_batch_list()
batch_list.add_batch(table, [(item2_key, item2_range),
(item3_key, item3_range)])
- response = c.batch_get_item(batch_list)
+ response = batch_list.submit()
assert len(response['Responses'][table.name]['Items']) == 2
# Try to delete the item with the right Expected value
Please sign in to comment.
Something went wrong with that request. Please try again.