class AbstractClientMixin: """Designed to be mixed in to a Protocol implementing class. Inherit from me first. @ivar _logonDeferred: Fired when I am done logging in. """ def __init__(self, account, chatui, logonDeferred): for base in self.__class__.__bases__: if issubclass(base, Protocol): self.__class__._protoBase = base break else: pass from dreamIRCTools import MessagePipe self.pipe = MessagePipe() self.account = account self.chat = chatui self._logonDeferred = logonDeferred def connectionMade(self): self.pipe.add(_("Connected to IRC server")) self._protoBase.connectionMade(self) def connectionLost(self, reason): self.account._clientLost(self, reason) self.unregisterAsAccountClient() self.pipe.add("Uuuups... Connection lost... %s" % reason) return self._protoBase.connectionLost(self, reason) def unregisterAsAccountClient(self): """Tell the chat UI that I have `signed off'. """ self.chat.unregisterAccountClient(self)
def __init__(self, account, chatui, logonDeferred): for base in self.__class__.__bases__: if issubclass(base, Protocol): self.__class__._protoBase = base break else: pass from dreamIRCTools import MessagePipe self.pipe = MessagePipe() self.account = account self.chat = chatui self._logonDeferred = logonDeferred