Twisted (software): Difference between revisions

Content deleted Content added
Bender the Bot (talk | contribs)
 
(43 intermediate revisions by 38 users not shown)
Line 1:
{{Short description|Event-driven network programming framework}}
{{Infobox software
| name = Twisted
| logo = [[File:Twisted Logo (software).svg|150px]]
| status logo size = Mature150px
| screenshot =
| caption =
| collapsible =
| author = [[Glyph Lefkowitz]]
| developer = Community
| released = {{Start date and age|2002|10|22}}<ref>{{Cite mailing list|last=Shtull-Trauring|first=Itamar|title=Twisted 1.0|date=2002-10-22|accessdateaccess-date=2008-08-14|mailinglistmailing-list=twisted-python|url=http://twistedmatrix.com/pipermail/twisted-python/2002-October/002049.html}}</ref>
| latest release version = {{wikidata|property|edit|reference|P348}}
| frequently updated = yes <!-- Release version update? Don't edit this page, just click on the version number! -->
| latest release date = {{start date and age|{{wikidata|qualifier|P348|P577}}}}
| latest preview version =
| latest preview date =
Line 16 ⟶ 19:
| size =
| language =
| status = Mature
| genre = [[event-driven programming|Event-driven]] [[computer network programming|networking]]
| license = [[MIT License]]
| website = {{URL|twistedmatrix.com}}
}}
 
'''Twisted''' is an [[event-driven programming|event-driven]] [[computer network programming|network programming]] [[software framework|framework]] written in [[Python (programming language)|Python]] and licensed under the [[MIT License]].
 
Twisted projects variously support [[Transmission Control Protocol|TCP]], [[User Datagram Protocol|UDP]], [[Transport Layer Security|SSL/TLS]], [[IP multicast]], Unix ___domain [[Unix ___domain socket|sockets]], a large number ofmany protocols (including [[HTTP]], [[Extensible Messaging and Presence Protocol|XMPP]], [[Network News Transfer Protocol|NNTP]], [[Internet Message Access Protocol|IMAP]], [[Secure Shell|SSH]], [[IRC]], [[File Transfer Protocol|FTP]], and others), and much more. Twisted is based on the [[event-driven programming]] paradigm, which means that users of Twisted write short [[callback (computer science)|callbacks]] which are called by the framework.
 
==Core ideas==
 
===Separation of protocols and transports===
Twisted is designed for complete separation between logical protocols (usually relying on stream-based connection semantics, such as HTTP or [[POP3]]) and physical transport layers supporting such stream-based semantics (such as files, sockets or SSL libraries). Connection between a logical protocol and a transport layer happens at the last possible moment — just before information is passed into the logical protocol instance. The logical protocol is informed of the transport layer instance, and can use it to send messages back and to check for the peer's identity. Note that it is still possible, in protocol code, to deeply query the transport layer on transport issues (such as checking a client-side SSL certificate). Naturally, such protocol code will fail ([[exception handling|raise an exception]]) if the transport layer does not support such semantics.
 
===Deferreds===
Central to the Twisted application model is the concept of a ''deferred'' (elsewhere called a ''[[future (programming)|future]]''). A deferred is an instance of a class designed to receive and process a result which has not been computed yet, for example because it is based on data from a remote peer. Deferreds can be passed around, just like regular objects, but cannot be asked for their value. Each deferred supports a callback chain. When the deferred gets the value, it is passed to the functions on the callback chain, with the result of each callback becoming the input for the next. Deferreds make it possible to arrange to operate on the result of a function call before its value has become available.

For example, if a deferred returns a string from a remote peer containing an [[IP address]] in quad format, a callback can be attached to translate it into a 32-bit number. Any user of the deferred can now treat it as a deferred returning a 32-bit number. This, and the related ability to define "errbacks" (callbacks which are called as error handlers), allows code to specify in advance what to do when an asynchronous event occurs, without stopping to wait for the event. In non-event-driven systems, for example using [[thread (computing)|threads]], the operating system incurs premature and additional overhead organizing threads each time a blocking call is made.
 
===Thread support===
Line 38 ⟶ 41:
 
===Foreign loop support===
Twisted can integrate with foreign event loops, such as those of [[GTK+]], [[Qt (framework)|Qt]] and [[Cocoa (API)|Cocoa]] (through [[PyObjC]]). This allows using Twisted as the networking supportnetwork layer in [[graphical user interface]] (GUI) programs, using all of its libraries without adding a thread-per-socket overhead, as using Python's native library would. A full-fledged web server can be integrated in-process with a GUI program using this model, for example.
 
==Applications using Twisted==
{{More citations needed section|date=March 2017}}
* The [[BuildBot]] continuous-integration system relies on Twisted for client/server communication.<ref>[http{{cite web|url=https://djmitche.github.com/buildbot/docs/0.7.10/#Requirements |title=BuildBot Manual]|website=github.com|access-date=2017-10-28|archive-url=https://web.archive.org/web/20120729232916/http://djmitche.github.com/buildbot/docs/0.7.10/#Requirements|archive-date=2012-07-29|url-status=dead}}</ref>
* [[ITA Software]] has developed an airline-reservation system for [[Air Canada]] that uses Twisted extensively.<ref>[{{cite web|url=http://www.eweek.com/c/a/Application-Development/Python-Slithers-into-Systems/1/ Page 2 - |title=Python Slithers into Systems<!-- Bot generated title -->]|website=eweek.com}}</ref>
* [[SageMath]], an open-source alternative to [[Mathematica]], [[Maple (software)|Maple]], [[Magma (computer algebra system)|Magma]], [[MATLAB]], has a web-based interface, SageMath notebook,<ref>[[SageMath#Features]]</ref> that runs on a Twisted server.<ref>[https://web.archive.org/web/20220516061211/http://sage.math.washington.edu/home/wdj/expository/gap2007/sage-9-2007.pdf Sage a Basic Overview ]</ref>
* Twisted was used in the [[Omegle]] one-on-one chat service<ref>[http{{cite web|url=https://omegler.blogspot.com/|title=mistah Official Omegle Blog]deejay|website=omegler.blogspot.com}}</ref> until it was replaced with gevent for performance reasons.<ref>[{{cite web|url=http://groups.google.com/group/gevent/msg/d15a840088291f61 Gevent |title=Google Group]Groups|website=groups.google.com}}</ref>
* The Apple Calendar Server uses Twisted,<ref>[{{cite web|url=http://www.calendarserver.org/ Darwin |title=Calendar Serverand OfficialContacts Site]Server|website=www.calendarserver.org}}</ref> as do some internal projects of [[NASA]].
* [[Conch (SSH)|Conch]], an implementation of the [[Secure Shell]] (SSH) protocol
* The original version of social networking and microblogging site [[Jaiku]] used Twisted.{{Citation needed|date=March 2017}}
* [[FluidDBFluidinfo]], an online cloud data-store, uses Twisted extensively for internal RPC (partly in combination with [[Thrift (protocol)|Thrift]] and [[AMQP]]), for its internal services, and for external APIs.
* The file-hosting service [[Ubuntu One]] used Twisted.
* [[Tor2web]], an HTTP proxy for [[Tor (anonymity network)#Hidden services|Tor Hidden Services (HS)]], uses Twisted.
* [[GlobaLeaks]], an open-source whistleblowing framework, uses Twisted.
* [[Cloudkick]], a cloud-server management web-application, used Twisted. It now has been rewritten using [[Node.js]].
* [[Twilio]], a cloud telephony provider, uses Twisted.
* [[TwitchTVTwitch (service)|Twitch]], a video game broadcasting and chat community, uses Twisted.<ref>{{cite web|url=http://www.twitch.tv/jobs|title=Twitch - Jobs|website=Twitch}}</ref>
* [[Velocity Weather]], a meteorological data processing and integration API is built on Twisted.<ref>{{cite web|url=http://www.velocityweather.com/|title=Velocity Weather -|website=www.velocityweather.com}}</ref>
* [[Warbenchqwebirc]], a creatorweb-based ofIRC productive online meetings platformclient, uses Twisted.
* [[qwebircZenoss Core]], a web-basednetwork IRCmanagement clientplatform, uses Twisted for many internal and collection daemons.
* [[Zenoss]], a network management platform, uses Twisted for many internal and collection daemons.
* [[Jasmin SMS Gateway]], a sms gateway with SMPP and HTTP APIs, mainly based on Twisted.
* [[Scrapy]], a web crawler based on Twisted.
* [[Listen to Wikipedia]], a [[Wikipedia]] audio-visualizer, uses Twisted to broadcast real-time edit events to browsers.<ref>{{Citation|title=A WebSocket-oriented monitor for Wikipedia (also, wikimon, wikital monsters)|date=2017-09-03|url=https://github.com/hatnote/wikimon|publisher=hatnote|access-date=2017-09-21}}</ref>
* [[Tahoe-LAFS]], a distributed data store and distributed file system.
* [[Deluge (software)|Deluge]], a highly modular [[BitTorrent]] client, uses Twisted.<ref>{{cite web|url=https://dev.deluge-torrent.org/wiki/Installing/Source|title=Deluge: build from source|website=dev.deluge-torrent.org|access-date=2020-01-08}}</ref>
* [[Magic Wormhole]], a secure file transfer tool using [[Password-authenticated key agreement|PAKE]].<ref>{{cite web|url=https://github.com/warner/magic-wormhole|title=Magic Wormhole|website=github.com}}</ref>
 
===Nevow===
{{Infobox software
| title =
| name = Nevow
| logo = <!-- [[File: ]] -->
| screenshot = <!-- [[File: ]] -->
| caption =
| collapsible =
| author = Donovan Preston<ref>[https://www.python.org/pycon/dc2004/papers/60/context this 2004 paper by Donovan Preston, the original author of Nevow and Formless] {{webarchive |url=https://web.archive.org/web/*/https://www.python.org/pycon/dc2004/papers/60/context |date=* }}</ref><ref>[http://soundfarmer.com/content/nevow.html Nevow: A Web Application Construction Kit], Donovan Preston</ref><ref>[http://article.gmane.org/gmane.comp.python.twisted/4973/ Subject: Re: ANN: Twisted 1.1.0, the framework of *your* internet], From: Donovan Preston, Date: 2003-10-27, Newsgroups: gmane.comp.python.twisted, ''nevow was originally a research project -- a weekend's worth of hacking whose benefits turned out to be so great that we decided to focus on bringing it up to a usable state for Quotient as soon as possible. And that's where it is now.''</ref>
| developer = Divmod
| released = {{Start date and age|2004|05|06}}<!-- from changelog *nevow-0.1 (06 May 2004) -->
| discontinued =
| latest release version = 0.14.4
| latest release date = {{Start date and age|2018|06|14}}<ref name="release">{{cite web | url=https://github.com/twisted/nevow/releases | title= Releases · twisted/nevow | website= [[GitHub]] | access-date=2020-11-04 }}</ref>
| latest preview version =
| latest preview date = <!-- {{Start date and age|YYYY|MM|DD}} -->
| programming language = [[Python (programming language)|Python]]
| operating system = [[Cross-platform]]
| platform =
| size =
| language =
| genre = [[Web application framework]]
| license = [[MIT License]]
}}
'''Nevow''' (pronounced like the French ''nouveau'') is a [[Python (programming language)|Python]] [[web application framework]] originally developed by the company Divmod. Template substitution is achieved via a small [[Tag Attribute Language]], which is usually embedded in on-disk [[XML]] templates, though there is also a pure-Python [[___domain-specific language]] called Stan, for expressing this markup programmatically. Nevow integrates well with Twisted.
 
Nevow was deployed on several high-profile [[web site]]s, most notably the official Python site.<ref>[https://wiki.python.org/moin/PythonWebsitePyramidDocs PythonWebsitePyramidDocs], ''Pyramid is the internal website templating system used to build the python.org pages. (It is not connected to the Pyramid web framework, formerly named BFG, that's used with Pylons.) Pyramid uses Nevow as its templating system and YAML as the format for its file based data'' - PythonInfo Wiki, python.org</ref>
 
As of mid-2010, Divmod went out of business,<ref>[http://glyph.twistedmatrix.com/2009/07/goodbye-divmod-hello-world.html Goodbye, Divmod. Hello, World!], July 10, 2009, Deciphering Glyph</ref> causing development work on Nevow to all but cease, and in 2011 its homepage was no longer accessible.<ref>[https://www.ohloh.net/p/nevow/commits Divmod Nevow commits] {{Webarchive|url=https://web.archive.org/web/20121015131618/https://www.ohloh.net/p/nevow/commits |date=2012-10-15 }} on [[Ohloh]]</ref> There is a project on [[Launchpad (website)|Launchpad]], hosting the source code of Divmod<ref>[http://divmod.org Divmod] {{webarchive|url=https://web.archive.org/web/20060813135423/http://divmod.org/ |date=August 13, 2006 }}</ref> including the source code of the Nevow project.<ref>[https://launchpad.net/divmod.org Divmod] on [[Launchpad (website)|Launchpad]]</ref>
 
==== Athena ====
Athena is a Nevow component which facilitates bi-directional, [[asynchronous communication]] between the Python and [[JavaScript]] portions of a web application in the form of [[remote procedure call]]s. This technique is typically called [[Ajax (programming)|Ajax]] or [[Comet (programming)|Comet]], though Nevow's implementation predates both of these labels.<ref>[http://divmodsphinx.funsize.net/nevow/chattutorial/#history History] {{Webarchive|url=https://web.archive.org/web/20160303203811/http://divmodsphinx.funsize.net/nevow/chattutorial/#history |date=2016-03-03 }}, Nevow Athena from Scratch, or The Evolution of a Chat Application — Divmod Nevow vtrunk documentation</ref> Athena also includes an [[inheritance (object-oriented programming)|inheritance]]-based JavaScript [[object system]], which forms the basis of a client-side ''[[GUI widget|widget]]'' abstraction, [[module (programming)|module system]] and in-[[web browser|browser]] [[unit test]]ing kit.
 
==See also==
{{Portal|Free and open-source software}}
* [[Application server]]
* [[Reactor pattern]]
* [[Perl Object Environment]], a comparable framework for the [[Perl]] programming language
* [[Netty (software)|Netty]], for the Java programming language
* [[Node.js]], for Javascript
* [[EventMachine]], an event-processing library for [[Ruby (programming language)|Ruby]]<ref>{{cite web |url=http://rubyeventmachine.com/ |title=EventMachine |accessdateaccess-date=20 August 2011}}</ref>
* [[Kivy (framework)]], a multi-platform GUI framework (including iOS and Android)<ref>{{cite web|url=http://kivy.org/docs/guide/other-frameworks.html|title=Integrating with other Frameworks — Kivy 1.11.0.dev0 documentation|website=kivy.org}}</ref>
 
==References==
Line 80 ⟶ 121:
[[Category:Free software programmed in Python]]
[[Category:Free system software]]
[[Category:Python (programming language) libraries]]
[[Category:Python (programming language) software]]
[[Category:Software using the MIT license]]