[Twisted-Python] How can I mix the proxy function into a special protocol
exarkun at divmod.com
Tue Jan 16 09:06:21 EST 2007
On Tue, 16 Jan 2007 04:17:09 +0000 (GMT), slowtech chen <slowtech.chen at yahoo.com> wrote:
>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:
>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.
More information about the Twisted-Python