Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: boto/sdb/db/model.py

Issue 8386013: Merging in latest boto. (Closed) Base URL: svn://svn.chromium.org/boto
Patch Set: Redoing vendor drop by deleting and then merging. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « boto/sdb/db/manager/xmlmanager.py ('k') | boto/sdb/db/property.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « boto/sdb/db/manager/xmlmanager.py ('k') | boto/sdb/db/property.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698