memdb conflict check, thanks Luca
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.7.4-stable+timestamp.2013.11.13.14.06.31
|
Version 2.7.4-stable+timestamp.2013.11.14.13.28.53
|
||||||
|
|||||||
@@ -253,12 +253,15 @@ class Table(DALStorage):
|
|||||||
|
|
||||||
self._db(self.id > 0).delete()
|
self._db(self.id > 0).delete()
|
||||||
|
|
||||||
def insert(self, **fields):
|
|
||||||
id = self._create_id()
|
def insert(self, **fields):
|
||||||
if self.update(id, **fields):
|
# Checks 3 times that the id is new. 3 times is enough!
|
||||||
return long(id)
|
for i in range(3):
|
||||||
|
id = self._create_id()
|
||||||
|
if self.get(id) is None and self.update(id, **fields):
|
||||||
|
return long(id)
|
||||||
else:
|
else:
|
||||||
return None
|
raise RuntimeError("Too many ID conflicts")
|
||||||
|
|
||||||
def get(self, id):
|
def get(self, id):
|
||||||
val = self._tableobj.get(self._id_to_key(id))
|
val = self._tableobj.get(self._id_to_key(id))
|
||||||
|
|||||||
Reference in New Issue
Block a user