[Twisted-web] How a script make a .tap file(a server)?

Steve Han hxianping at gmail.com
Sat Dec 30 00:59:41 CST 2006

I am working on an example from here

from twisted.internet.app import Application
from twisted.internet.protocol import Protocol, Factory

class Fibonacci(Protocol):
    """Serve a sequence of Fibonacci numbers to all requesters"""

def dataReceived(self, data):
        self.factory.new = self.factory.a + self.factory.b
        self.transport.write('%d' % self.factory.new)
        self.factory.a = self.factory.b
        self.factory.b = self.factory.new

def main():
    import fib_server    # Use script as namespace
    f = Factory()
    f.protocol = fib_server.Fibonacci
    f.a, f.b = 1, 1
    application = Application("Fibonacci")
    application.listenTCP(8888, f)

if'__main__' == __name__:

I have questions as the following:

   1. I could not find where in the code above make a .tap file?
   2. testing on "twistd -f Fibonacci.tap" got message "Failed to load
   application: No module named fib_server".Can we use script as namespace?

Steve Han
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20061230/7c90750d/attachment.htm

More information about the Twisted-web mailing list