Re: [Twisted-Python] Implementing a new stream transport
On Apr 8, 2013, at 3:47 PM, Laurens Van Houtven _...@lvh.cc wrote: On Apr 8, 2013 9:44 PM, Phil Budne p...@ultimate.com wrote: As a quick crock, I made my transport a subclass of twisted.internet.tcp.Server, and got away with it, but I'd like to do the right thing. I'd be delighted to find out that mixins exist that would solve my problem, but I'd be happy to know what interfaces I need to implement, or even better where I find find documentation on how to implement a new transport, especially one that isn't file-descriptor based. Are you familiar with interfaces? ITransport sounds like what you want. Saying that ITransport is sufficient is unfortunately a bit simplistic. I am not sure about our HTTP server, but many protocols rely on other interfaces provided by Server, including: from twisted.internet.tcp import Server from zope.interface import implementedBy from pprint import pprint from twisted.python.reflect import qual pprint([qual(x) for x in implementedBy(Server)]) ['twisted.internet.interfaces.ITCPTransport', 'twisted.internet.interfaces.ISystemHandle', 'twisted.internet.interfaces.ITLSTransport', 'twisted.internet.interfaces.IPushProducer', 'twisted.internet.interfaces.IReadWriteDescriptor', 'twisted.internet.interfaces.IConsumer', 'twisted.internet.interfaces.ITransport', 'twisted.internet.interfaces.IHalfCloseableDescriptor', 'twisted.internet.interfaces.ILoggingContext'] It might be useful to note the possible presence of some of these in the documentation for servers and clients. -glyph ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Implementing a new stream transport
On Tue, Apr 9, 2013 at 5:58 AM, Phil Budne p...@ultimate.com wrote: Yes, and I implemented the ITransport methods. The first bump was that I was missing registerProducer and unregisterProducer, which are defined as part of IConsumer. But after that I had another problem (which I can't reproduce at this moment). Huh. If the interface you're passing it to claims it needs an ITransport, and an ITransport didn't work, that's a bug. The consumer/producer interfaces are somewhat related to transports, but definitely distinct. Could you paste some code that you tried illustrating the problem? (You mentioned something involving Sites and Protocols, but a Site is a ServerFactory.) -- cheers lvh ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Implementing a new stream transport
On 04/09/2013 06:29 AM, Laurens Van Houtven wrote: On Tue, Apr 9, 2013 at 5:58 AM, Phil Budne p...@ultimate.com mailto:p...@ultimate.com wrote: Yes, and I implemented the ITransport methods. The first bump was that I was missing registerProducer and unregisterProducer, which are defined as part of IConsumer. But after that I had another problem (which I can't reproduce at this moment). Huh. If the interface you're passing it to claims it needs an ITransport, and an ITransport didn't work, that's a bug. The consumer/producer interfaces are somewhat related to transports, but definitely distinct. I'm pretty sure the twisted.web server code uses the consumer API on the transport. ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
[Twisted-Python] Implementing a new stream transport
I looked for, but haven't (yet) found any documentation on how to implement a Twisted transport For some testing and prototype work I'm doing I implemented the proprietary TCP connection multiplexing protocol a customer of mine uses as a Twisted Protocol and a transport for the channels that are multiplexed inside the real TCP connection. When I tried running a twisted.web.server.Site Protocol on my new channel transport I found I was missing members and methods in the transport class. As a quick crock, I made my transport a subclass of twisted.internet.tcp.Server, and got away with it, but I'd like to do the right thing. I'd be delighted to find out that mixins exist that would solve my problem, but I'd be happy to know what interfaces I need to implement, or even better where I find find documentation on how to implement a new transport, especially one that isn't file-descriptor based. Thanks! Phil ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Implementing a new stream transport
On Apr 8, 2013 9:44 PM, Phil Budne p...@ultimate.com wrote: As a quick crock, I made my transport a subclass of twisted.internet.tcp.Server, and got away with it, but I'd like to do the right thing. I'd be delighted to find out that mixins exist that would solve my problem, but I'd be happy to know what interfaces I need to implement, or even better where I find find documentation on how to implement a new transport, especially one that isn't file-descriptor based. Are you familiar with interfaces? ITransport sounds like what you want. Thanks! Phil ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Implementing a new stream transport
Laurens Van Houtven wrote: Are you familiar with interfaces? ITransport sounds like what you want. Yes, and I implemented the ITransport methods. The first bump was that I was missing registerProducer and unregisterProducer, which are defined as part of IConsumer. But after that I had another problem (which I can't reproduce at this moment). Phil ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python