jlafon/PynamoDB — pull request #43 by greenwoodcm (2014-11-03 06:43:03+00:00)
Title: added version attribute for optimistic locking on create and update

This commit adds support for optimistic locking based on a version attribute. This is similar to the functionality provided in the Java DynamoDBMapper:

http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBMapper.html

This is implemented using a special case of numerical attribute and allowing the save() method to auto-increment that value (or initialize it on create). It will also add to the expected values sent in the conditional put so as to enforce that the record has not been modified since the last read. There is currently no handling of the version attribute in the delete() operation, I'm not exactly sure what that would entail, but I'm open to suggestions.