[Twisted-Python] Problem and clueless what it is....

Chaz. eprparadocs at gmail.com
Wed Jun 14 14:01:35 MDT 2006


I've written a simple protocol, factory and service and can't seem to
get it to work right. It is so simple that I can't seem to figure out
the problem.

Here is the code:

---------------------------------------------------------

# Import standard python modules
from random import random
from cmath import exp


# Import 3rd party modules
from twisted.internet.protocol import DatagramProtocol, ServerFactory
from twisted.internet import reactor
from twisted.application import internet


class NeedFilesServer(DatagramProtocol) :
    def datagramReceived(self, dgram, sourceIP) :
        if dgram == 'HELPNeedFiles' :
		self.transport.write(IAmHere",sourceIP)

class NeedFilesFactory(ServerFactory):
    protocol = NeedFilesServer

class NeedFilesService(internet.UDPServer):
    def __init__(self,wkp):
        internet.UDPServer.__init__(self,wkp,NeedFilesFactory())

-----------------------------------------------------------------

When I do the standard application thing...

application = service.Application('foo')
srv = service.MultiService()
NeedFilesSrv = NeedFilesService(config['wkp'])
NeedFilesSrv.setServiceParent(srv)
srv.setServiceParent(service.IServiceCollection(application))

I get a the following trace:

Traceback (most recent call last):
2006/06/14 15:23 EDT [-]   File "/usr/bin/twistd", line 25, in ?
2006/06/14 15:23 EDT [-]     run()
2006/06/14 15:23 EDT [-]   File
"/usr/lib64/python2.4/site-packages/twisted/scripts/twistd.py", line
205, in run
2006/06/14 15:23 EDT [-]     app.run(runApp, ServerOptions)
2006/06/14 15:23 EDT [-]   File
"/usr/lib64/python2.4/site-packages/twisted/application/app.py", line
278, in run
2006/06/14 15:23 EDT [-]     runApp(config)
2006/06/14 15:23 EDT [-]   File
"/usr/lib64/python2.4/site-packages/twisted/scripts/twistd.py", line
196, in runApp
2006/06/14 15:23 EDT [-]     startApplication(config, application)
2006/06/14 15:23 EDT [-]   File
"/usr/lib64/python2.4/site-packages/twisted/scripts/twistd.py", line
173, in startApplication
2006/06/14 15:23 EDT [-]
service.IService(application).privilegedStartService()
2006/06/14 15:23 EDT [-]   File
"/usr/lib64/python2.4/site-packages/twisted/application/service.py",
line 191, in privilegedStartService
2006/06/14 15:23 EDT [-]     service.privilegedStartService()
2006/06/14 15:23 EDT [-]   File
"/usr/lib64/python2.4/site-packages/twisted/application/service.py",
line 191, in privilegedStartService
2006/06/14 15:23 EDT [-]     service.privilegedStartService()
2006/06/14 15:23 EDT [-]   File
"/usr/lib64/python2.4/site-packages/twisted/application/internet.py",
line 68, in privilegedStartService
2006/06/14 15:23 EDT [-]     self._port = self._getPort()
2006/06/14 15:23 EDT [-]   File
"/usr/lib64/python2.4/site-packages/twisted/application/internet.py",
line 86, in _getPort
2006/06/14 15:23 EDT [-]     return getattr(reactor,
'listen'+self.method)(*self.args, **self.kwargs)
2006/06/14 15:23 EDT [-]   File
"/usr/lib64/python2.4/site-packages/twisted/internet/posixbase.py", line
307, in listenUDP
2006/06/14 15:23 EDT [-]     p.startListening()
2006/06/14 15:23 EDT [-]   File
"/usr/lib64/python2.4/site-packages/twisted/internet/udp.py", line 85,
in startListening
2006/06/14 15:23 EDT [-]     self._connectToProtocol()
2006/06/14 15:23 EDT [-]   File
"/usr/lib64/python2.4/site-packages/twisted/internet/udp.py", line 105,
in _connectToProtocol
2006/06/14 15:23 EDT [-]     self.protocol.makeConnection(self)
2006/06/14 15:23 EDT [-] AttributeError: NeedFilesFactory instance has
no attribute 'makeConnection'


I've looked at the FTP protocol code and I seem to be doing the same
things.

Does anyone know what I am doing wrong?

Thanks in advance,
Chaz.




More information about the Twisted-Python mailing list