Commit bc534916 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Node got an asTuple() method that return it's content as required by protocol

packet encoder (for node information notifications)


git-svn-id: https://svn.erp5.org/repos/neo/trunk@1329 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 00840676
......@@ -48,14 +48,7 @@ class AdminEventHandler(EventHandler):
def node_filter(n):
return n.getType() is node_type
node_list = self.app.nm.getList(node_filter)
node_information_list = []
for node in node_list:
try:
ip, port = node.getAddress()
except TypeError:
ip = "0.0.0.0"
port = 0
node_information_list.append((node.getType(), (ip, port), node.getUUID(), node.getState()))
node_information_list = [node.asTuple() for node in node_list ]
p = protocol.answerNodeList(node_information_list)
conn.answer(p, packet.getId())
......
......@@ -352,12 +352,7 @@ class Application(object):
node_list = []
for n in self.nm.getList():
if not n.isAdmin():
node_list.append((
n.getType(),
n.getAddress(),
n.getUUID(),
n.getState()
))
node_list.append(n.asTuple())
# Split the packet if too huge.
if len(node_list) == 10000:
conn.notify(protocol.notifyNodeInformation(node_list))
......
......@@ -128,6 +128,10 @@ class Node(object):
def setPending(self):
self.setState(protocol.PENDING_STATE)
def asTuple(self):
""" Returned tuple is intented to be used in procotol encoders """
return (self.getType(), self._address, self._uuid, self._state)
# XXX: for comptatibility, to be removed
def getType(self):
try:
......
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