~ubuntu-branches/ubuntu/trusty/python-boto/trusty

« back to all changes in this revision

Viewing changes to boto/sdb/db/model.py

  • Committer: Package Import Robot
  • Author(s): Eric Evans
  • Date: 2012-04-15 20:21:21 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20120415202121-3fpf6q355s0xqpyu
Tags: 2.3.0-1
* New upstream release (Closes: #664478)
* Update debian/watch for Boto's move to Github.  Thanks Scott
  Moser. (Closes: #650480)

Show diffs side-by-side

added added

removed removed

Lines of Context:
188
188
            self._manager.load_object(self)
189
189
 
190
190
    def put(self, expected_value=None):
 
191
        """
 
192
        Save this object as it is, with an optional expected value
 
193
 
 
194
        :param expected_value: Optional tuple of Attribute, and Value that 
 
195
            must be the same in order to save this object. If this 
 
196
            condition is not met, an SDBResponseError will be raised with a
 
197
            Confict status code.
 
198
        :type expected_value: tuple or list
 
199
        :return: This object
 
200
        :rtype: :class:`boto.sdb.db.model.Model`
 
201
        """
191
202
        self._manager.save_object(self, expected_value)
 
203
        return self
192
204
 
193
205
    save = put
 
206
 
 
207
    def put_attributes(self, attrs):
 
208
        """
 
209
        Save just these few attributes, not the whole object
 
210
 
 
211
        :param attrs: Attributes to save, key->value dict
 
212
        :type attrs: dict
 
213
        :return: self
 
214
        :rtype: :class:`boto.sdb.db.model.Model`
 
215
        """
 
216
        assert(isinstance(attrs, dict)), "Argument must be a dict of key->values to save"
 
217
        for prop_name in attrs:
 
218
            value = attrs[prop_name]
 
219
            prop = self.find_property(prop_name)
 
220
            assert(prop), "Property not found: %s" % prop_name
 
221
            self._manager.set_property(prop, self, prop_name, value)
 
222
        self.reload()
 
223
        return self
 
224
 
 
225
    def delete_attributes(self, attrs):
 
226
        """
 
227
        Delete just these attributes, not the whole object.
 
228
 
 
229
        :param attrs: Attributes to save, as a list of string names
 
230
        :type attrs: list
 
231
        :return: self
 
232
        :rtype: :class:`boto.sdb.db.model.Model`
 
233
        """
 
234
        assert(isinstance(attrs, list)), "Argument must be a list of names of keys to delete."
 
235
        self._manager.domain.delete_attributes(self.id, attrs)
 
236
        self.reload()
 
237
        return self
 
238
 
 
239
    save_attributes = put_attributes
194
240
        
195
241
    def delete(self):
196
242
        self._manager.delete_object(self)