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