Commit 46390f7c authored by Grégory Wisniewski's avatar Grégory Wisniewski

Do not give a new instance in 'dict.setdefault'.

This create an object each time a transaction or object is stored, even if the entry is found in the dictionnary.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1641 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent d9e19865
...@@ -124,8 +124,10 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -124,8 +124,10 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
def askStoreTransaction(self, conn, tid, user, desc, def askStoreTransaction(self, conn, tid, user, desc,
ext, oid_list): ext, oid_list):
uuid = conn.getUUID() uuid = conn.getUUID()
app = self.app t = self.app.transaction_dict.get(tid, None)
t = app.transaction_dict.setdefault(tid, TransactionInformation(uuid)) if t is None:
t = TransactionInformation(uuid)
self.app.transaction_dict[tid] = t
if t.isLastOIDChanged(): if t.isLastOIDChanged():
self.app.dm.setLastOID(self.app.loid) self.app.dm.setLastOID(self.app.loid)
t.addTransaction(oid_list, user, desc, ext) t.addTransaction(oid_list, user, desc, ext)
...@@ -158,7 +160,10 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler): ...@@ -158,7 +160,10 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
conn.answer(Packets.AnswerStoreObject(1, oid, last_serial)) conn.answer(Packets.AnswerStoreObject(1, oid, last_serial))
return return
# Now store the object. # Now store the object.
t = app.transaction_dict.setdefault(tid, TransactionInformation(uuid)) t = self.app.transaction_dict.get(tid, None)
if t is None:
t = TransactionInformation(uuid)
self.app.transaction_dict[tid] = t
t.addObject(oid, compression, checksum, data) t.addObject(oid, compression, checksum, data)
conn.answer(Packets.AnswerStoreObject(0, oid, serial)) conn.answer(Packets.AnswerStoreObject(0, oid, serial))
app.store_lock_dict[oid] = tid app.store_lock_dict[oid] = tid
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment