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()
|
||||
|
||||
def insert(self, **fields):
|
||||
id = self._create_id()
|
||||
if self.update(id, **fields):
|
||||
return long(id)
|
||||
|
||||
def insert(self, **fields):
|
||||
# Checks 3 times that the id is new. 3 times is enough!
|
||||
for i in range(3):
|
||||
id = self._create_id()
|
||||
if self.get(id) is None and self.update(id, **fields):
|
||||
return long(id)
|
||||
else:
|
||||
return None
|
||||
raise RuntimeError("Too many ID conflicts")
|
||||
|
||||
def get(self, id):
|
||||
val = self._tableobj.get(self._id_to_key(id))
|
||||
|
||||
Reference in New Issue
Block a user