Commit dd19dfe1 authored by Vincent Pelletier's avatar Vincent Pelletier

Replace "__call__" by "encode" so it is easier to identify its users.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1869 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent ab70852f
......@@ -418,7 +418,7 @@ class Connection(BaseConnection):
was_empty = not bool(self.write_buf)
PACKET_LOGGER.dispatch(self, packet, ' to ')
self.write_buf += packet()
self.write_buf += packet.encode()
if was_empty:
# enable polling for writing.
......
......@@ -263,7 +263,7 @@ class Packet(object):
def getType(self):
return self.__class__
def __call__(self):
def encode(self):
""" Encode a packet as a string to send it over the network """
content = self._body
length = PACKET_HEADER_SIZE + len(content)
......
......@@ -421,7 +421,7 @@ class ConnectionTests(NeoTestBase):
def test_07_Connection_addPacket(self):
# no connector
p = Mock({"__call__" : "testdata"})
p = Mock({"encode" : "testdata"})
em = Mock()
handler = Mock()
bc = Connection(em, handler, connector_handler=DoNothingConnector,
......@@ -494,7 +494,7 @@ class ConnectionTests(NeoTestBase):
(("127.0.0.1", 2132), self.getNewUUID()))
p = Packets.AnswerPrimary(self.getNewUUID(), master_list)
p.setId(1)
bc.read_buf += p()
bc.read_buf += p.encode()
self.assertEqual(len(bc.event_dict), 0)
bc.analyse()
# check packet decoded
......@@ -528,7 +528,7 @@ class ConnectionTests(NeoTestBase):
(("127.0.0.1", 2132), self.getNewUUID()))
p1 = Packets.AnswerPrimary(self.getNewUUID(), master_list)
p1.setId(1)
bc.read_buf += p1()
bc.read_buf += p1.encode()
# packet 2
master_list = (
(("127.0.0.1", 2135), self.getNewUUID()),
......@@ -541,7 +541,7 @@ class ConnectionTests(NeoTestBase):
(("127.0.0.1", 2132), self.getNewUUID()))
p2 = Packets.AnswerPrimary( self.getNewUUID(), master_list)
p2.setId(2)
bc.read_buf += p2()
bc.read_buf += p2.encode()
self.assertEqual(len(bc.read_buf), len(p1) + len(p2))
self.assertEqual(len(bc.event_dict), 0)
bc.analyse()
......@@ -599,7 +599,7 @@ class ConnectionTests(NeoTestBase):
(("127.0.0.1", 2132), self.getNewUUID()))
p = Packets.AnswerPrimary(self.getNewUUID(), master_list)
p.setId(1)
bc.read_buf += p()
bc.read_buf += p.encode()
self.assertEqual(len(bc.event_dict), 0)
bc.expectMessage(1)
self.assertEqual(len(bc.event_dict), 1)
......@@ -729,7 +729,7 @@ class ConnectionTests(NeoTestBase):
uuid = self.getNewUUID()
p = Packets.AnswerPrimary(uuid, master_list)
p.setId(1)
return p()
return p.encode()
DoNothingConnector.receive = receive
connector = DoNothingConnector()
bc = Connection(em, handler, connector_handler=DoNothingConnector,
......
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