| Index: boto/sdb/db/model.py
|
| diff --git a/boto/sdb/db/model.py b/boto/sdb/db/model.py
|
| index 18bec4b95cd144981a7ea32a363bfc8d91ef176a..eab82763f9bdf53e39fd5b8c03a4edb8bfeb2a4c 100644
|
| --- a/boto/sdb/db/model.py
|
| +++ b/boto/sdb/db/model.py
|
| @@ -187,10 +187,56 @@ class Model(object):
|
| self._loaded = False
|
| self._manager.load_object(self)
|
|
|
| - def put(self):
|
| - self._manager.save_object(self)
|
| + def put(self, expected_value=None):
|
| + """
|
| + Save this object as it is, with an optional expected value
|
| +
|
| + :param expected_value: Optional tuple of Attribute, and Value that
|
| + must be the same in order to save this object. If this
|
| + condition is not met, an SDBResponseError will be raised with a
|
| + Confict status code.
|
| + :type expected_value: tuple or list
|
| + :return: This object
|
| + :rtype: :class:`boto.sdb.db.model.Model`
|
| + """
|
| + self._manager.save_object(self, expected_value)
|
| + return self
|
|
|
| save = put
|
| +
|
| + def put_attributes(self, attrs):
|
| + """
|
| + Save just these few attributes, not the whole object
|
| +
|
| + :param attrs: Attributes to save, key->value dict
|
| + :type attrs: dict
|
| + :return: self
|
| + :rtype: :class:`boto.sdb.db.model.Model`
|
| + """
|
| + assert(isinstance(attrs, dict)), "Argument must be a dict of key->values to save"
|
| + for prop_name in attrs:
|
| + value = attrs[prop_name]
|
| + prop = self.find_property(prop_name)
|
| + assert(prop), "Property not found: %s" % prop_name
|
| + self._manager.set_property(prop, self, prop_name, value)
|
| + self.reload()
|
| + return self
|
| +
|
| + def delete_attributes(self, attrs):
|
| + """
|
| + Delete just these attributes, not the whole object.
|
| +
|
| + :param attrs: Attributes to save, as a list of string names
|
| + :type attrs: list
|
| + :return: self
|
| + :rtype: :class:`boto.sdb.db.model.Model`
|
| + """
|
| + assert(isinstance(attrs, list)), "Argument must be a list of names of keys to delete."
|
| + self._manager.domain.delete_attributes(self.id, attrs)
|
| + self.reload()
|
| + return self
|
| +
|
| + save_attributes = put_attributes
|
|
|
| def delete(self):
|
| self._manager.delete_object(self)
|
|
|