{{{ #!div class="column-layout" style="display: table;" {{{ #!div class="leftcol" style="display: table-cell" {{{ #!div class="leftcolcol" {{{ #!div id="download" [[Image(/chrome/common/download_icon.png, id=download_icon, title=Downloads, alt="", link=wiki:Downloads)]] = Downloads = == Source == * [[ProjectVersion(http://pypi.python.org/packages/source/T/Twisted/Twisted-%(base)s.tar.bz2#md5=%(md5)s Twisted %(base)s tar.bz2)]] == Windows (32-bit) == * [[ProjectVersion(http://pypi.python.org/packages/2.7/T/Twisted/Twisted-%(base)s.win32-py2.7.msi Twisted %(base)s for Python 2.7)]] * [[ProjectVersion(http://pypi.python.org/packages/2.6/T/Twisted/Twisted-%(base)s.win32-py2.6.msi Twisted %(base)s for Python 2.6)]] * [[ProjectVersion(http://pypi.python.org/packages/2.5/T/Twisted/Twisted-%(base)s.win32-py2.5.msi Twisted %(base)s for Python 2.5)]] == Other == * [wiki:Downloads More downloads] == Dependencies == * [http://pypi.python.org/pypi/zope.interface#download zope.interface] }}} {{{ #!div class="side-panel twisted-news" == [http://labs.twistedmatrix.com/ Twisted News] == {{{ #!div id="twisted-news" class="feed-content" [[Image(/chrome/common/throbber.gif, link=, class=throbber, title="", alt="")]] }}} }}} {{{ #!div class="side-panel donations" == Donate to Twisted == Donations are [wiki:TwistedSoftwareFoundation#Background tax-deductible]. {{{ #!html
}}} = [wiki:TwistedSponsors Twisted Sponsors] = [wiki:TwistedSoftwareFoundation Become a 2012 sponsor today]! For any donation above [wiki:TwistedSoftwareFoundation#SponsorshipLevels the bronze level], we will display your logo here on the front page. {{{ #!div class="twisted-sponsors" === Silver === [[Image(TSF/SponsorLogos:Appropriate-Solutions-Inc.gif, title=Appropriate Solutions Inc, link=http://www.appropriatesolutions.com/)]] [[Image(TSF/SponsorLogos:dreamhost.gif, title=DreamHost, link=http://dreamhost.com/?q=twisted)]] [[Image(TSF/SponsorLogos:simb.png, title=SIMB, link=http://www.simb.com.br/)]] === Bronze === [[Image(TSF/SponsorLogos:dyn-logo.png, title=Dynamic Network Services Inc, link=http://www.dyn.com/)]] }}} }}} }}} }}} {{{ #!div class="centercol" style="display: table-cell" = What is Twisted? = Twisted is an event-driven networking engine written in Python and licensed under the open source [http://www.opensource.org/licenses/mit-license.php MIT license]. == Code Examples == {{{ #!html }}} {{{ #!div class="tab-content" {{{ #!div class="tab-pane active" id="echoserver" Twisted makes it easy to implement custom network applications. Here's a TCP server that echoes back everything that's written to it: {{{ #!python from twisted.internet import protocol, reactor class Echo(protocol.Protocol): def dataReceived(self, data): self.transport.write(data) class EchoFactory(protocol.Factory): def buildProtocol(self, addr): return Echo() reactor.listenTCP(1234, EchoFactory()) reactor.run() }}} Learn more about [http://twistedmatrix.com/documents/current/core/howto/servers.html writing servers], [http://twistedmatrix.com/documents/current/core/howto/clients.html writing clients] and the [http://twistedmatrix.com/documents/current/core/howto/index.html core networking libraries ], including support for SSL, UDP, scheduled events, unit testing infrastructure, and much more. }}} {{{ #!div class="tab-pane" id="webserver" Twisted includes an event-driven web server. Here's a sample web application; notice how the resource object persists in memory, rather than being recreated on each request: {{{ #!python from twisted.web import server, resource from twisted.internet import reactor class HelloResource(resource.Resource): isLeaf = True numberRequests = 0 def render_GET(self, request): self.numberRequests += 1 request.setHeader("content-type", "text/plain") return "I am request #" + str(self.numberRequests) + "\n" reactor.listenTCP(8080, server.Site(HelloResource())) reactor.run() }}} Learn more about [http://twistedmatrix.com/documents/current/web/howto/web-in-60/index.html web application development], [http://twistedmatrix.com/documents/current/web/howto/twisted-templates.html templates] and Twisted's [http://twistedmatrix.com/documents/current/web/howto/client.html HTTP client]. }}} {{{ #!div class="tab-pane" id="pubsubserver" Here's a simple publish/subscribe server, where clients see all messages posted by other clients: {{{ #!python from twisted.internet import reactor, protocol from twisted.protocols import basic class PubProtocol(basic.LineReceiver): delimiter = "\n" def __init__(self, factory): self.factory = factory def connectionMade(self): self.factory.clients.add(self) def connectionLost(self, reason): self.factory.clients.remove(self) def lineReceived(self, line): message = "<%s> %s\n" % (self.transport.getHost(), line) for c in self.factory.clients: if c != self: c.transport.write(message) class PubFactory(protocol.Factory): def __init__(self): self.clients = set() def buildProtocol(self, addr): return PubProtocol(self) if __name__ == '__main__': reactor.listenTCP(1025, PubFactory()) reactor.run() }}} }}} }}} == More Protocols == Twisted also supports many common network protocols, including SMTP, POP3, IMAP, SSHv2, and DNS. For more information see our [wiki:Documentation documentation] and [http://twistedmatrix.com/documents/current/api/ API reference]. == Community == [[Image(http://oreilly.com/catalog/covers/twistedadn.s.gif, title=The Twisted Book, align=right, link=http://www.amazon.com/gp/product/0596100329?ie=UTF8&tag=jpcalsjou-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0596100329)]] * Get in touch with the [wiki:TwistedCommunity Twisted community] through [wiki:TwistedCommunity#MailLists email], [http://stackoverflow.com/questions/tagged/twisted Stack Overflow] or [wiki:TwistedCommunity#IRC IRC]; * Learn about the Twisted [wiki:TwistedDevelopment development process] and how to [wiki:ContributingToTwistedLabs contribute]; * Read about [wiki:ProjectsUsingTwisted software using] Twisted and their [wiki:SuccessStories success stories]; * Find out what [wiki:TwistedMatrixLaboratories Twisted Matrix Laboratories] is; * Learn about the [wiki:TwistedSponsors individuals and organisations] that aid Twisted with donations of hardware, software, hosting and other things; * Help improve Twisted on [wiki:Windows Windows]! }}}