It seems quite unpythonic to force users to write such constructs when dealing with the oh-so-useful conditional operations in DynamoDM:
try:
thread_item.save(Thread.forum_name.exists())
except PutError as e:
if isinstance(e.cause, ClientError):
code = e.cause.response['Error'].get('Code')
print(code == "ConditionalCheckFailedException")
PynamoDB already issues it own exceptions - why not perform this if and raise a ConditionalCheckFailed? why perpetuate the bad API for boto3 (in this regard) into this otherwise very pythonic library?
Make this work:
try:
thread_item.save(Thread.forum_name.exists())
except ConditionalCheckFailed:
pass
It seems quite unpythonic to force users to write such constructs when dealing with the oh-so-useful conditional operations in DynamoDM:
PynamoDB already issues it own exceptions - why not perform this
ifand raise aConditionalCheckFailed? why perpetuate the bad API for boto3 (in this regard) into this otherwise very pythonic library?Make this work: