[Twisted-Python] How can I mix the proxy function into a special protocol
Hi guys, I tried to do this with multiple inheritances: class MyProxyServer(basic.Int32StringReceiver, ProxyServer): def dataReceived(self, data): basic.Int32StringReceiver.dataReceived(self, data) ProxyServer.dataReceived(self, data) but I got the following errors: self.peer.transport.write(data) exceptions.AttributeError: 'NoneType' object has no attribute 'transport' why the setPeer method of ProxyServer isn't called here? Are there any better solutions for this problem? Thanks. Best, Chen ____________________________________________________________________________________ No need to miss a message. Get email on-the-go with Yahoo! Mail for Mobile. Get started. http://mobile.yahoo.com/mail
On Tue, 16 Jan 2007 04:17:09 +0000 (GMT), slowtech chen <slowtech.chen@yahoo.com> wrote:
Hi guys,
I tried to do this with multiple inheritances:
class MyProxyServer(basic.Int32StringReceiver, ProxyServer): def dataReceived(self, data): basic.Int32StringReceiver.dataReceived(self, data) ProxyServer.dataReceived(self, data)
but I got the following errors:
self.peer.transport.write(data) exceptions.AttributeError: 'NoneType' object has no attribute 'transport'
why the setPeer method of ProxyServer isn't called here? Are there any better solutions for this problem?
Probably because you didn't call it. Anyhow, I wouldn't suggest doing this, anyway. ProxyServer is all of about 10 lines long. It takes about as much code to import, subclass, and upcall to it as it would take to implement yourself. Generally I wouldn't recommend re-implementing something which already exists, but there's so little code involved here and ProxyServer isn't really intended to be subclassed like this. Jean-Paul
participants (2)
-
Jean-Paul Calderone
-
slowtech chen