Commit 3ca8ea08 authored by Vincent Pelletier's avatar Vincent Pelletier

Deprecate connection's getHandler.

parent b181b08b
...@@ -258,6 +258,7 @@ class BaseConnection(object): ...@@ -258,6 +258,7 @@ class BaseConnection(object):
event_manager.register(self) event_manager.register(self)
event_manager.addReader(self) event_manager.addReader(self)
# XXX: do not use getHandler
getHandler = property(lambda self: self._handlers.getHandler) getHandler = property(lambda self: self._handlers.getHandler)
getLastHandler = property(lambda self: self._handlers.getLastHandler) getLastHandler = property(lambda self: self._handlers.getLastHandler)
isPending = property(lambda self: self._handlers.isPending) isPending = property(lambda self: self._handlers.isPending)
......
...@@ -117,6 +117,13 @@ class Node(object): ...@@ -117,6 +117,13 @@ class Node(object):
assert force is not None, \ assert force is not None, \
attributeTracker.whoSet(self, '_connection') attributeTracker.whoSet(self, '_connection')
# The test on peer_id is there to protect against buggy nodes. # The test on peer_id is there to protect against buggy nodes.
# XXX: handler comparison does not cover all cases: there may
# be a pending handler change, which won't be detected, or a future
# handler change which is not prevented. Complete implementation
# should allow different handlers for each connection direction,
# with in-packets client/server indicators to decide which handler
# (server-ish or client-ish) to use. There is currently no need for
# the full-fledged functionality, and it is simpler this way.
if not force or conn.getPeerId() is not None or \ if not force or conn.getPeerId() is not None or \
type(conn.getHandler()) is not type(connection.getHandler()): type(conn.getHandler()) is not type(connection.getHandler()):
raise ProtocolError("already connected") raise ProtocolError("already connected")
......
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