from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor
class Server(Protocol):
def connectionMade(self):
self.transport.write(self.factory.quote+'\r\n')
def connectionLost(self, reason):
print 'connection lost ...'
def dataReceived(self, data):
print data
self.transport.write(data)
class ServerFactory(Factory):
protocol = Server
def __init__(self, quote=None):
self.quote = quote
reactor.listenTCP(8007, ServerFactory("quote"))
reactor.run()
Traceback (most recent call last):
File "serv.py", line 1, in <module>
from twisted.internet.protocol import Factory, Protocol
File "/usr/lib/python2.6/dist-packages/twisted/__init__.py", line 18, in <module>
from twisted.python import compat
File "/usr/lib/python2.6/dist-packages/twisted/python/compat.py", line 99, in <module>
except (AttributeError, NameError, socket.error):
AttributeError: 'module' object has no attribute 'error'
Питон: 2.6
Twisted: 10.1.0
Это проблема в модуле? Или пример не правильный?