[Twisted-Python] Not subclassing internet.TCPServer

Chaz. eprparadocs at gmail.com
Thu Aug 24 14:30:48 EDT 2006


In my code :

class StorageService(internet.TCPServer):
     def __init__(self,tcpPort,configInfo):
         r = StoragePeer(configInfo)
         xmlrpc.addIntrospection(r)
         internet.TCPServer.__init__(self,tcpPort,server.Site(r))

I specifically used internet.TCPServer as a parent class so that I could 
do a .setServiceParent() on the object returned.

If I rewrite the code as:

class StorageService:
     def __init__(self,tcpPort,configInfo):
         r = StoragePeer(configInfo)
         xmlrpc.addIntrospection(r)
         self.r = internet.TCPServer(tcpPort,server.Site(r))

     def setServiceParent(self,arg) :
         self.r.setServiceParent(arg)

I get an equivalent effect.

So my question is why is subclassing internet.TCPServer not a good idea?


Chaz






More information about the Twisted-Python mailing list