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

Side by Side 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, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « boto/sdb/db/manager/xmlmanager.py ('k') | boto/sdb/db/property.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/ 1 # Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/
2 # 2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a 3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the 4 # copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including 5 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish, dis- 6 # without limitation the rights to use, copy, modify, merge, publish, dis-
7 # tribute, sublicense, and/or sell copies of the Software, and to permit 7 # tribute, sublicense, and/or sell copies of the Software, and to permit
8 # persons to whom the Software is furnished to do so, subject to the fol- 8 # persons to whom the Software is furnished to do so, subject to the fol-
9 # lowing conditions: 9 # lowing conditions:
10 # 10 #
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 def load(self): 181 def load(self):
182 if self.id and not self._loaded: 182 if self.id and not self._loaded:
183 self._manager.load_object(self) 183 self._manager.load_object(self)
184 184
185 def reload(self): 185 def reload(self):
186 if self.id: 186 if self.id:
187 self._loaded = False 187 self._loaded = False
188 self._manager.load_object(self) 188 self._manager.load_object(self)
189 189
190 def put(self): 190 def put(self, expected_value=None):
191 self._manager.save_object(self) 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 """
202 self._manager.save_object(self, expected_value)
203 return self
192 204
193 save = put 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 ke ys 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 def delete(self): 241 def delete(self):
196 self._manager.delete_object(self) 242 self._manager.delete_object(self)
197 243
198 def key(self): 244 def key(self):
199 return Key(obj=self) 245 return Key(obj=self)
200 246
201 def set_manager(self, manager): 247 def set_manager(self, manager):
202 self._manager = manager 248 self._manager = manager
203 249
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 285
240 def __getattr__(self, name): 286 def __getattr__(self, name):
241 if not name.startswith('_'): 287 if not name.startswith('_'):
242 value = self._manager.get_key_value(self, name) 288 value = self._manager.get_key_value(self, name)
243 if value: 289 if value:
244 object.__setattr__(self, name, value) 290 object.__setattr__(self, name, value)
245 return value 291 return value
246 raise AttributeError 292 raise AttributeError
247 293
248 294
OLDNEW
« 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