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

Side by Side Diff: boto/sdb/db/manager/pgmanager.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/__init__.py ('k') | boto/sdb/db/manager/sdbmanager.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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 return self._object_from_row(row, self.cursor.description) 354 return self._object_from_row(row, self.cursor.description)
355 else: 355 else:
356 raise SDBPersistenceError('%s object with id=%s does not exist' % (c ls.__name__, id)) 356 raise SDBPersistenceError('%s object with id=%s does not exist' % (c ls.__name__, id))
357 357
358 def get_object_from_id(self, id): 358 def get_object_from_id(self, id):
359 return self.get_object(self.cls, id) 359 return self.get_object(self.cls, id)
360 360
361 def _find_calculated_props(self, obj): 361 def _find_calculated_props(self, obj):
362 return [p for p in obj.properties() if hasattr(p, 'calculated_type')] 362 return [p for p in obj.properties() if hasattr(p, 'calculated_type')]
363 363
364 def save_object(self, obj): 364 def save_object(self, obj, expected_value=None):
365 obj._auto_update = False 365 obj._auto_update = False
366 calculated = self._find_calculated_props(obj) 366 calculated = self._find_calculated_props(obj)
367 if not obj.id: 367 if not obj.id:
368 obj.id = str(uuid.uuid4()) 368 obj.id = str(uuid.uuid4())
369 qs, values = self._build_insert_qs(obj, calculated) 369 qs, values = self._build_insert_qs(obj, calculated)
370 else: 370 else:
371 qs, values = self._build_update_qs(obj, calculated) 371 qs, values = self._build_update_qs(obj, calculated)
372 print qs 372 print qs
373 self.cursor.execute(qs, values) 373 self.cursor.execute(qs, values)
374 if calculated: 374 if calculated:
375 calc_values = self.cursor.fetchone() 375 calc_values = self.cursor.fetchone()
376 print calculated 376 print calculated
377 print calc_values 377 print calc_values
378 for i in range(0, len(calculated)): 378 for i in range(0, len(calculated)):
379 prop = calculated[i] 379 prop = calculated[i]
380 prop._set_direct(obj, calc_values[i]) 380 prop._set_direct(obj, calc_values[i])
381 self.commit() 381 self.commit()
382 382
383 def delete_object(self, obj): 383 def delete_object(self, obj):
384 qs = """DELETE FROM "%s" WHERE id='%s';""" % (self.db_table, obj.id) 384 qs = """DELETE FROM "%s" WHERE id='%s';""" % (self.db_table, obj.id)
385 print qs 385 print qs
386 self.cursor.execute(qs) 386 self.cursor.execute(qs)
387 self.commit() 387 self.commit()
388 388
389 389
OLDNEW
« no previous file with comments | « boto/sdb/db/manager/__init__.py ('k') | boto/sdb/db/manager/sdbmanager.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698