Commit a59d5f3a authored by Vincent Pelletier's avatar Vincent Pelletier

Factorise "ask" access.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2409 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent fb969137
...@@ -105,6 +105,7 @@ class ReplicationHandler(EventHandler): ...@@ -105,6 +105,7 @@ class ReplicationHandler(EventHandler):
@checkConnectionIsReplicatorConnection @checkConnectionIsReplicatorConnection
def answerTIDsFrom(self, conn, tid_list): def answerTIDsFrom(self, conn, tid_list):
app = self.app app = self.app
ask = conn.ask
# If I have pending TIDs, check which TIDs I don't have, and # If I have pending TIDs, check which TIDs I don't have, and
# request the data. # request the data.
tid_set = frozenset(tid_list) tid_set = frozenset(tid_list)
...@@ -116,7 +117,7 @@ class ReplicationHandler(EventHandler): ...@@ -116,7 +117,7 @@ class ReplicationHandler(EventHandler):
deleteTransaction(tid) deleteTransaction(tid)
missing_tid_set = tid_set - my_tid_set missing_tid_set = tid_set - my_tid_set
for tid in missing_tid_set: for tid in missing_tid_set:
conn.ask(Packets.AskTransactionInformation(tid), timeout=300) ask(Packets.AskTransactionInformation(tid), timeout=300)
@checkConnectionIsReplicatorConnection @checkConnectionIsReplicatorConnection
def answerTransactionInformation(self, conn, tid, def answerTransactionInformation(self, conn, tid,
...@@ -129,6 +130,7 @@ class ReplicationHandler(EventHandler): ...@@ -129,6 +130,7 @@ class ReplicationHandler(EventHandler):
@checkConnectionIsReplicatorConnection @checkConnectionIsReplicatorConnection
def answerObjectHistoryFrom(self, conn, object_dict): def answerObjectHistoryFrom(self, conn, object_dict):
app = self.app app = self.app
ask = conn.ask
my_object_dict = app.replicator.getObjectHistoryFromResult() my_object_dict = app.replicator.getObjectHistoryFromResult()
deleteObject = app.dm.deleteObject deleteObject = app.dm.deleteObject
for oid, serial_list in object_dict.iteritems(): for oid, serial_list in object_dict.iteritems():
...@@ -143,7 +145,7 @@ class ReplicationHandler(EventHandler): ...@@ -143,7 +145,7 @@ class ReplicationHandler(EventHandler):
else: else:
missing_serial_set = serial_list missing_serial_set = serial_list
for serial in missing_serial_set: for serial in missing_serial_set:
conn.ask(Packets.AskObject(oid, serial, None), timeout=300) ask(Packets.AskObject(oid, serial, None), timeout=300)
@checkConnectionIsReplicatorConnection @checkConnectionIsReplicatorConnection
def answerObject(self, conn, oid, serial_start, def answerObject(self, conn, oid, serial_start,
......
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