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): ...@@ -48,14 +48,7 @@ class AdminEventHandler(EventHandler):
def node_filter(n): def node_filter(n):
return n.getType() is node_type return n.getType() is node_type
node_list = self.app.nm.getList(node_filter) node_list = self.app.nm.getList(node_filter)
node_information_list = [] node_information_list = [node.asTuple() for node in node_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()))
p = protocol.answerNodeList(node_information_list) p = protocol.answerNodeList(node_information_list)
conn.answer(p, packet.getId()) conn.answer(p, packet.getId())
......
...@@ -352,12 +352,7 @@ class Application(object): ...@@ -352,12 +352,7 @@ class Application(object):
node_list = [] node_list = []
for n in self.nm.getList(): for n in self.nm.getList():
if not n.isAdmin(): if not n.isAdmin():
node_list.append(( node_list.append(n.asTuple())
n.getType(),
n.getAddress(),
n.getUUID(),
n.getState()
))
# Split the packet if too huge. # Split the packet if too huge.
if len(node_list) == 10000: if len(node_list) == 10000:
conn.notify(protocol.notifyNodeInformation(node_list)) conn.notify(protocol.notifyNodeInformation(node_list))
......
...@@ -128,6 +128,10 @@ class Node(object): ...@@ -128,6 +128,10 @@ class Node(object):
def setPending(self): def setPending(self):
self.setState(protocol.PENDING_STATE) 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 # XXX: for comptatibility, to be removed
def getType(self): def getType(self):
try: 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