[Twisted-Python] Implementing a new stream transport
Glyph
glyph at twistedmatrix.com
Thu Apr 11 02:43:01 EDT 2013
On Apr 8, 2013, at 3:47 PM, Laurens Van Houtven <_ at lvh.cc> wrote:
> On Apr 8, 2013 9:44 PM, "Phil Budne" <phil at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20130411/eaf94513/attachment.htm
More information about the Twisted-Python
mailing list