[Twisted-Python] What's so cool about Twisted?
(Yes, Glyph, I know it leads to increased sexual potency.) The really short version of this email: What features/tools/etc. does Twisted offer, how do they differ from conventional APIs/programs, and what do they do? (E.g. Sessions vs. cookies, Widgets, Passport....) What would its "feature list" look like? The longer version: The recent message about CGI/Sessions got me wondering how Twisted differs from other 'net frameworks, and how I can capitalize on its advantages. For example, I'm planning on running a blog on top of Twisted (all I need is a computer to code on...:P). On a standard web server, I'd probably set most of it up as CGIs, at least initially, and use cookies for dealing with "members" and such. But Twisted's got these things called Sessions and Passports, and I've seen a lot of bits thrown about in regard to Widgets. And there's probably a lot of stuff I haven't heard about. I know there's the "Why Twisted?" section, but it's *extremely* high-level, basically saying "It's written in Python, has a bunch of different protocols that can interface, and is well-supported," which is like someone handing you a tool box and telling you, "There are some really useful tools in here. They're like ones you may have heard about, but better." "So...why are they better? What do they do? Why would I want this tool set over a different one?" I realize at least part of this comes from my ignorance regarding network programming; I'm basically a neophyte when it comes to that. Otherwise, I could probably dive into the code and figure out what does what, and how it's different or better than the way things are normally done. As it is, I wouldn't know where to start. Once I know what the parts are and what they do, I should be able to use my m4D Py7h0n sKi11Z (;-}) to figure out the "how". Thanks in advance, Mike
On Thu, 2001-12-20 at 17:26, Michael Dartt wrote:
(Yes, Glyph, I know it leads to increased sexual potency.)
The really short version of this email: What features/tools/etc. does Twisted offer, how do they differ from conventional APIs/programs, and what do they do? (E.g. Sessions vs. cookies, Widgets, Passport....) What would its "feature list" look like?
I really wish I could point you at a complete feature list; right now, though, a lot of things are in flux. This is a complaint that I've heard before though, so if you manage to get a good idea of what Twisted is from reading a combination of code, list archives, and documentation snippets that we've written, a concise write-up of that would be really valuable.
The longer version:
The recent message about CGI/Sessions got me wondering how Twisted differs from other 'net frameworks, and how I can capitalize on its advantages. For example, I'm planning on running a blog on top of Twisted (all I need is a computer to code on...:P). On a standard web server, I'd probably set most of it up as CGIs, at least initially, and use cookies for dealing with "members" and such. But Twisted's got these things called Sessions and Passports, and I've seen a lot of bits thrown about in regard to Widgets. And there's probably a lot of stuff I haven't heard about.
For this specific case, I can answer you: You will need to know about twisted.web.widgets and twisted.enterprise (probably the version we're working on right now, still unreleased). There are copious comments in Widgets, and Enterprise has a fairly small API, documentation is forthcoming. As far as sessions go; they're just an automatically managed cookie with some arbitrarily-associated state. The API is simply that a Request object has a method getSession, which will return a Session instance; set or get any attributes you like on that object; it has no relevant methods. These session objects expire every half an hour of inactivity or so. Finally, twisted.forum (still unreleased, I believe; I've got to get moving on the next release!) will probably provide you with a good bit of straightforward example code for how to do these sort of things.
I know there's the "Why Twisted?" section, but it's *extremely* high-level, basically saying "It's written in Python, has a bunch of different protocols that can interface, and is well-supported," which is like someone handing you a tool box and telling you, "There are some really useful tools in here. They're like ones you may have heard about, but better." "So...why are they better? What do they do? Why would I want this tool set over a different one?"
A lot of the really cool functionality in Twisted is still being developed. The main interesting thing about Twisted is that it's a platform for developing integrated functionality, not in any one bit of functionality that exists at this time. This is a feature which is hard to describe, especially to non-technical people *cough*management*cough*. This makes it better than the average web platform because on the average web platform, it would not be possible to integrate a chat program with your webserver and have it access the same data. Decoupling your data into a relational database can help, but you still end up with process synchronization and communication problems; not to mention the fact that ALL data that you want to have accessible through the chat interface must be represented in the database. With Twisted, lots of people are working on lots of parts of the networking infrastructure at once. It's ideal for games, but it's also ideal for web applications. Given the factoring of the code, there is a lot of common code at each level, so as we reimplement, optimize, refactor, and enhance various pieces of the codebase to support, let's say, a multiplayer game, the webserver and IRC server get better too.
I realize at least part of this comes from my ignorance regarding network programming; I'm basically a neophyte when it comes to that. Otherwise, I could probably dive into the code and figure out what does what, and how it's different or better than the way things are normally done. As it is, I wouldn't know where to start. Once I know what the parts are and what they do, I should be able to use my m4D Py7h0n sKi11Z (;-}) to figure out the "how".
Learning network programming is a task in itself, and learning Twisted could probably help you through it. Some of the confusing stuff is in the style of programming that Twisted encourages, which is to say event-based rather than threaded. Some of the confusing stuff is in the various bits of Twisted that use Python's internals to make things happen "behind the scenes". In general, however, sample programs with Twisted are short and to the point, and you can focus on the particular problems of your application domain (See doc/examples in the Twisted distribution.) In the absence of documentation, ask questions either on this list or in the #python channel on irc.openprojects.net; there will often be developers there who can help you. Usually this mailing list is helpful too, I *ahem* ENCOURAGE other developers to help newbies and write documentation ;). I will try to turn salient mailing list posts into HTML documentation in a timely manner, but I make no promimses. Happy hacking, -- ______ you are in a maze of twisted little applications, all | |_\ remarkably consistent. | | -- glyph lefkowitz, glyph @ twisted matrix . com |_____| http://www.twistedmatrix.com/
participants (2)
-
Glyph Lefkowitz
-
Michael Dartt