Commit 0a122977 authored by Vincent Pelletier's avatar Vincent Pelletier

Drop support for event queue kwargs.

This is not used currently, and prevents method argument extension.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2572 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 95a6d72a
......@@ -318,27 +318,27 @@ class Application(object):
if not node.isHidden():
break
def queueEvent(self, some_callable, conn, *args, **kwargs):
def queueEvent(self, some_callable, conn, *args):
msg_id = conn.getPeerId()
self.event_queue.append((some_callable, msg_id, conn, args, kwargs))
self.event_queue.append((some_callable, msg_id, conn, args))
def executeQueuedEvents(self):
l = len(self.event_queue)
p = self.event_queue.popleft
for _ in xrange(l):
some_callable, msg_id, conn, args, kwargs = p()
some_callable, msg_id, conn, args = p()
if conn.isAborted() or conn.isClosed():
continue
conn.setPeerId(msg_id)
some_callable(conn, *args, **kwargs)
some_callable(conn, *args)
def logQueuedEvents(self):
if self.event_queue is None:
return
neo.logging.info("Pending events:")
for event, _msg_id, _conn, args, _kwargs in self.event_queue:
for event, _msg_id, _conn, args in self.event_queue:
neo.logging.info(' %r: %r:%r %r %r', event.__name__, _msg_id,
_conn, args, _kwargs)
_conn, args)
def shutdown(self, erase=False):
"""Close all connections and exit"""
......
......@@ -121,27 +121,26 @@ class StorageAppTests(NeoUnitTestBase):
msg_id = 1325136
event = Mock({'__repr__': 'event'})
conn = Mock({'__repr__': 'conn', 'getPeerId': msg_id})
self.app.queueEvent(event, conn, "test", key="value")
self.app.queueEvent(event, conn, "test")
self.assertEqual(len(self.app.event_queue), 1)
_event, _msg_id, _conn, args, kw = self.app.event_queue[0]
_event, _msg_id, _conn, args = self.app.event_queue[0]
self.assertEqual(msg_id, _msg_id)
self.assertEqual(len(args), 1)
self.assertEqual(args[0], "test")
self.assertEqual(kw, {"key" : "value"})
def test_03_executeQueuedEvents(self):
self.assertEqual(len(self.app.event_queue), 0)
msg_id = 1325136
event = Mock({'__repr__': 'event'})
conn = Mock({'__repr__': 'conn', 'getPeerId': msg_id})
self.app.queueEvent(event, conn, "test", key="value")
self.app.queueEvent(event, conn, "test")
self.app.executeQueuedEvents()
self.assertEquals(len(event.mockGetNamedCalls("__call__")), 1)
call = event.mockGetNamedCalls("__call__")[0]
params = call.getParam(1)
self.assertEqual(params, "test")
params = call.kwparams
self.assertEqual(params, {'key': 'value'})
self.assertEqual(params, {})
if __name__ == '__main__':
unittest.main()
......
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