Commit 2b87c2c2 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Rename Ask Object By OID and Answer Object By OID to Ask Object and Answer...

Rename Ask Object By OID and Answer Object By OID to Ask Object and Answer Object, respectively. Add a tid parameter to Ask Object. Correct handlers.

git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@65 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 13b54fcc
......@@ -15,7 +15,7 @@ from protocol import ERROR, REQUEST_NODE_IDENTIFICATION, ACCEPT_NODE_IDENTIFICAT
NOTIFY_INFORMATION_LOCKED, INVALIDATE_OBJECTS, UNLOCK_INFORMATION, \
ASK_NEW_OIDS, ANSWER_NEW_OIDS, ASK_STORE_OBJECT, ANSWER_STORE_OBJECT, \
ABORT_TRANSACTION, ASK_STORE_TRANSACTION, ANSWER_STORE_TRANSACTION, \
ASK_OBJECT_BY_OID, ANSWER_OBJECT_BY_OID, ASK_TIDS, ANSWER_TIDS, ASK_TRANSACTION_INFORMATION, \
ASK_OBJECT, ANSWER_OBJECT, ASK_TIDS, ANSWER_TIDS, ASK_TRANSACTION_INFORMATION, \
ANSWER_TRANSACTION_INFORMATION, ASK_OBJECT_HISTORY, ANSWER_OBJECT_HISTORY, \
NOT_READY_CODE, OID_NOT_FOUND_CODE, SERIAL_NOT_FOUND_CODE, TID_NOT_FOUND_CODE, \
PROTOCOL_ERROR_CODE, TIMEOUT_ERROR_CODE, BROKEN_NODE_DISALLOWED_CODE, \
......@@ -225,11 +225,11 @@ class EventHandler(object):
def handleAnswerStoreTransaction(self, conn, packet, tid):
self.handleUnexpectedPacket(conn, packet)
def handleAskObjectByOID(self, conn, packet, oid, serial):
def handleAskObject(self, conn, packet, oid, serial, tid):
self.handleUnexpectedPacket(conn, packet)
def handleAnswerObjectByOID(self, conn, packet, oid, serial_start,
serial_end, compression, checksum, data):
def handleAnswerObject(self, conn, packet, oid, serial_start,
serial_end, compression, checksum, data):
self.handleUnexpectedPacket(conn, packet)
def handleAskTIDs(self, conn, packet, first, last, spec):
......@@ -312,8 +312,8 @@ class EventHandler(object):
d[ABORT_TRANSACTION] = self.handleAbortTransaction
d[ASK_STORE_TRANSACTION] = self.handleAskStoreTransaction
d[ANSWER_STORE_TRANSACTION] = self.handleAnswerStoreTransaction
d[ASK_OBJECT_BY_OID] = self.handleAskObjectByOID
d[ANSWER_OBJECT_BY_OID] = self.handleAnswerObjectByOID
d[ASK_OBJECT] = self.handleAskObject
d[ANSWER_OBJECT] = self.handleAnswerObject
d[ASK_TIDS] = self.handleAskTIDs
d[ANSWER_TIDS] = self.handleAnswerTIDs
d[ASK_TRANSACTION_INFORMATION] = self.handleAskTransactionInformation
......
......@@ -143,11 +143,13 @@ ASK_STORE_TRANSACTION = 0x001a
# Answer if transaction has been stored. S -> C.
ANSWER_STORE_TRANSACTION = 0x801a
# Ask a stored object by its OID and serial if given. C -> S.
ASK_OBJECT_BY_OID = 0x001b
# Ask a stored object by its OID and a serial or a TID if given. If a serial
# is specified, the specified revision of an object will be returned. If
# a TID is specified, an object right before the TID will be returned. C -> S.
ASK_OBJECT = 0x001b
# Answer the requested object. S -> C.
ANSWER_OBJECT_BY_OID = 0x801b
ANSWER_OBJECT = 0x801b
# Ask for TIDs between a range of offset. C -> S.
ASK_TIDS = 0x001d
......@@ -556,18 +558,18 @@ class Packet(object):
self._body = pack('!B8s8s', conflicting, oid, serial)
return self
def askObjectByOID(self, msg_id, oid, serial):
def askObject(self, msg_id, oid, serial, tid):
self._id = msg_id
self._type = ASK_OBJET_BY_OID
self._body = pack('!8s8s', oid, serial)
self._type = ASK_OBJECT
self._body = pack('!8s8s8s', oid, serial, tid)
return self
def answerObjectByOID(self, msg_id, oid, serial_start, serial_end, compression,
checksum, data):
def answerObject(self, msg_id, oid, serial_start, serial_end, compression,
checksum, data):
self._id = msg_id
self._type = ANSWER_OBJECT_BY_OID
self._body = pack('!8s8s8sBLL', oid, serial_start, serial_end, compression,
checksum, len(data)) + data
self._type = ANSWER_OBJECT
self._body = pack('!8s8s8sBLL', oid, serial_start, serial_end,
compression, checksum, len(data)) + data
return self
def askTIDs(self, msg_id, first, last, spec):
......@@ -1001,25 +1003,25 @@ class Packet(object):
return tid
decode_table[ANSWER_STORE_TRANSACTION] = _decodeAnswerStoreTransaction
def _decodeAskObjectByOID(self):
def _decodeAskObject(self):
try:
oid, serial = unpack('8s8s', self._body)
oid, serial, tid = unpack('8s8s8s', self._body)
except:
raise ProtocolError(self, 'invalid ask object by oid')
return oid, serial
decode_table[ASK_OBJECT_BY_OID] = _decodeAskObjectByOID
raise ProtocolError(self, 'invalid ask object')
return oid, serial, tid
decode_table[ASK_OBJECT] = _decodeAskObject
def _decodeAnswerObjectByOID(self):
def _decodeAnswerObject(self):
try:
oid, serial_start, serial_end, compression, checksum, data_len \
= unpack('!8s8s8sBLL', self._body[:33])
data = self._body[33:]
except:
raise ProtocolError(self, 'invalid answer object by oid')
raise ProtocolError(self, 'invalid answer object')
if len(data) != data_len:
raise ProtocolError(self, 'invalid data size')
return oid, serial, compression, checksum, data
decode_table[ANSWER_OBJECT_BY_OID] = _decodeAnswerObjectByOID
return oid, serial_start, serial_end, compression, checksum, data
decode_table[ANSWER_OBJECT] = _decodeAnswerObject
def _decodeAskTIDs(self):
try:
......
......@@ -180,3 +180,7 @@ class StorageEventHandler(EventHandler):
def handleUnlockInformation(self, conn, packet, tid):
raise NotImplementedError('this method must be overridden')
def handleAskStoreObject(self, conn, packet, msg_id, oid, serial,
compression, data, checksum, tid):
pass
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