Changeset 1830
- Timestamp:
- 01/17/12 10:01:42 (4 months ago)
- Files:
-
- 1 modified
-
DjHDGutils/trunk/dbutils.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
DjHDGutils/trunk/dbutils.py
r1829 r1830 249 249 250 250 class LockForUpate(object): 251 252 def lock_for_update(self): 253 """ 254 lock object for update 255 Return locked object 256 257 """ 251 def _raw_lock(self): 258 252 cursor = connection.cursor() 259 253 cursor.execute("""select id from \"%s\" where id=%%s for update""" % self._meta.db_table, … … 263 257 transaction.set_dirty() 264 258 return type(self).objects.get(pk=self.id) 259 260 def _native_lock(self): 261 return type(self).objects.select_for_update().get(pk=self.id) 262 263 def lock_for_update(self): 264 """ 265 lock object for update 266 Return locked object 267 268 """ 269 if hasattr(self._base_manager, 'select_for_update'): 270 return self._native_lock() 271 272 return self._raw_lock() 265 273 266 274
