[Twisted-Python] twisted.net refactoring

Moshe Zadka moshez at zadka.site.co.il
Mon Apr 16 17:07:08 EDT 2001

I've started to work on refactoring twisted.net for minimal dependancies.
Currently, in the vein of "research project", what interests me is how
layering of protocols in an event-oriented framework can be accomplished.
Please have a look at http://moshez.org/protocols.tgz
I've written tests for all the protocol handlers I wrote, and I'd
be happy to work with anyone who wants to write tests for the irc client
and telnet server.

Basically, the idea is to turn low-level events (basically just handleData)
into high level events (like handleRequest, for HTTP, at the other end
of the spectrum). The idea is to reflect the layering of protocols (and 
only the layering of protocols -- read on) in the classes. 

So, inheritance happens when the spec references another spec -- e.g.,
XML-RPC is defined to be over HTTP, so it would be correct to have

class XMLRPCHandler(HTTPHandler):

    def handleRequest(self, command, selector, version, request):
        ...parse request into Python tuple...
        result = self.handleMethod(params)
        ....return HTTP response...

But, on the other hand, HTTP does not say anything about TCP/IP, so
HTTP should *not* be layered above any transport. This allows us to
use SSL, SOCKS or files just as well.

One big advantage I'm interested in is testability -- see the examples
already there to get my point -- you can bombard your handler hard-coded
strings and watch for the answers.
"I'll be ex-DPL soon anyway so I'm        |LUKE: Is Perl better than Python?
looking for someplace else to grab power."|YODA: No...no... no. Quicker,
   -- Wichert Akkerman (on debian-private)|      easier, more seductive.
For public key, finger moshez at debian.org  |http://www.{python,debian,gnu}.org

More information about the Twisted-Python mailing list