Skip to content

Commit

Permalink
Revert "Added "lookup" and "new_item" to dynamodb2.table, which makes…
Browse files Browse the repository at this point in the history
… it more"

This reverts commit 0059db7.
  • Loading branch information
toastdriven committed Jul 24, 2013
1 parent ddd3052 commit d4a2d79
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions boto/dynamodb2/table.py
Expand Up @@ -418,48 +418,6 @@ def get_item(self, consistent=False, **kwargs):
item.load(item_data)
return item

def lookup(self, hash_key=None, range_key=None, consistent=False, **kwargs):
"""
Look up an entry in DynamoDB. This is mostly backwards compatible
with boto.dynamodb. Unlike get_item, it takes hash_key and range_key first,
although you may still specify keyword arguments instead.
Also unlike the get_item command, if the returned item has no keys
(i.e., it does not exist in DynamoDB), a None result is returned, instead
of an empty key object.
Example::
>>> user = users.lookup(username)
>>> user = users.lookup(username, consistent=True)
>>> app = apps.lookup('my_customer_id', 'my_app_id')
"""
if not self.schema:
self.describe()
if hash_key:
kwargs[self.schema[0].name] = hash_key
if range_key and len(self.schema) > 1:
kwargs[self.schema[1].name] = range_key
ret = self.get_item(consistent, **kwargs)
if not ret.keys():
return None
return ret

def new_item(self, hash_key, range_key=None):
"""
Returns a new, blank item
This is mostly for consistency with boto.dynamodb
"""
if not self.schema:
self.describe()
data = {}
data[self.schema[0].name] = hash_key
if range_key and len(self.schema) > 1:
data[self.schema[1].name] = range_key
return Item(self, data=data)


def put_item(self, data, overwrite=False):
"""
Saves an entire item to DynamoDB.
Expand Down

0 comments on commit d4a2d79

Please sign in to comment.