[Twisted-Python] Re: Teach Me Twisted?

glyph at divmod.com glyph at divmod.com
Wed Jan 23 19:36:42 EST 2008

On 12:10 am, clemesha at gmail.com wrote:
>Thanks Steve Holden for organizing this, it's a great idea.

>Some nice topics might include:

Thanks for the suggestions.  Do you have any others?  :-)  I hate to 
rain on your parade here, but I think maybe my explanation of why I 
don't like these suggestions will spark discussion of more different 
>a) Start off simple with a "twisted.web2" example (everyone "gets" 

I think that this is actually something we should avoid in a tutorial. 
The web situation in Twisted is complicated 
(http://twistedmatrix.com/trac/wiki/WebDevelopmentWithTwisted).  web2 in 
particular is suffering from an extreme lack of maintenance and still 
has never "officially" been released; work is just starting to get 
underway to unify t.web2 and nevow into t.web and reduce the confusion, 
but this is all still in progress and who knows when, how, or even if it 
will be completed.  If you get a group of experienced Twisted folks 
together to talk about writing web applications, you're more likely to 
spark a debate than an educational session.

Even if all these problems were fixed, and there were a really good, 
well-supported, universally understood web server for Twisted, the 
benefits of Twisted's programming model are not immediately obvious to 
the bread and butter of the web programming world.  Learning how to use 
some combination of Twisted tools to generate a web page will always be 
at least a little bit harder than writing the sort of glorified CGI 
script that most web frameworks require these days - unless you're using 
something like Athena, which might be too much complexity to address in 
a single tutorial session.  (And while Athena is more polished and "one 
right way" than the lower-level HTTP stuff, there is still a painful 
dearth of documentation, not to mention the fact that you need to write 
JavaScript as well as Python.)

Twisted really shines best when you're writing a client as well as a 
server.  Chat is the quintessential application where Twisted makes the 
most sense - and the lack of a well-documented chat server is much less 
of a problem than the lack of a well-documented web server, since you 
can easily define a wire protocol and wacky semantics for your purpose- 
built tutorial chat application.
>b) then plug that into a simple sqlite database using 

twisted.enterprise is similarly a scary and inconsistent area, and 
requires understanding the interaction of the DB thread and the reactor 
thread.  (And at least part of this section would have to be dedicated 
to "and never, ever touch anything in this package aside from adbapi".)
>d) Show how using "twistd" is really convient
>(i.e. "twistd -ny server.tac" and "twistd -y server.tac", with some 
>capability, etc)

This, however, is a great suggestion.  Twisted plugins should be part of 
this discussion.

More information about the Twisted-Python mailing list