Adds the ConditionalCheckFailedException to put_item
If the Item‘s original data is inconsistent with what's in DynamoDB, the request should fail (unless overwrite is set to True). http://boto.readthedocs.org/en/latest/ref/dynamodb2.html#boto.dynamodb2.table.Table.put_item
This commit is contained in:
parent
abb3357925
commit
e3c859868c
2 changed files with 43 additions and 4 deletions
|
|
@ -134,7 +134,17 @@ class DynamoHandler(BaseResponse):
|
|||
def put_item(self):
|
||||
name = self.body['TableName']
|
||||
item = self.body['Item']
|
||||
result = dynamodb_backend2.put_item(name, item)
|
||||
overwrite = 'Expected' not in self.body
|
||||
if not overwrite:
|
||||
expected = self.body['Expected']
|
||||
else:
|
||||
expected = None
|
||||
|
||||
try:
|
||||
result = dynamodb_backend2.put_item(name, item, expected, overwrite)
|
||||
except Exception:
|
||||
er = 'com.amazonaws.dynamodb.v20111205#ConditionalCheckFailedException'
|
||||
return self.error(er)
|
||||
|
||||
if result:
|
||||
item_dict = result.to_json()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue