When Twisted started to explode onto the scene, I was really intrigued by its varied capabilities and asynchronous model, but I was turned off by the then-scant documentation and the webapp framework transition that was just beginning (Woven was deprecated and Nevow was too new for any sort of coherent explanation). I just didn't have time to wrap my head around it, and so Twisted fell off my radar screen for a while. Eventually, I saw that a book was on the way, and I was excited to jump back in with it as my guide.
Twisted Network Programming Essentials is not an exhaustive reference to Twisted, nor does it even pretend to be. Rather, it's a pretty friendly, task-oriented exploration, providing examples of common tasks and insight into the key concepts and design patterns that are essential to grokking Twisted. Each chapter focuses on a particular topic, and they're arranged to build upon each other nicely. Sections within each chapter are broken down into a practical, easily digested structure--we're introduced to the task at hand, then the "How do I do that?" and "How does it work?" bits clearly and plainly walk us through an example solution and dissect its inner workings. At 202 pages of actual text, its eleven chapters make for a comfortable chapter-per-evening of reading and play. It's well worth either keying in or downloading the example code to see Twisted in action.
Covered topics include installing Twisted, the essential Twisted concepts; HTTP clients and servers; various flavors of RPC; authentication; mail clients and servers (POP and IMAP); NNTP clients and servers; fun with SSH; and some practical, non-glamorous things like running your app as a proper daemon, adding administrative interfaces, and logging. You'll monitor download progress, make a simple blog, build an IMAP server, and more. You'll chain protocols together to make an email interface to Google. You'll be impressed by the power and cleanliness of Twisted's authentication model, and you'll have fun getting and using references to remote Python objects with Perspective Broker. There's also a pretty good explanation of REST, and plenty of links to useful reading.
All is unfortunately not shiny and delicious, though. I encountered what I consider quite a few programming errors in the example code, as well as several places where the explanatory text doesn't quite jive with the example. These errors are all fairly minor, and are probably artifacts of the evolution of the text and examples, but the frequency with which they crop up suggested that either no one had run the code before approving it for printing, or that errors were deliberately introduced to see if the reader is paying attention. As someone with a professional investment in web applications and frameworks, I was disappointed not to see any investigation of Nevow (not stable enough at the time of writing to be included, alas). The SSH chapter mentions but does not discuss or dive into the file transfer and connection tunneling concepts. I was also let down by the strict focus on programs that only used the basic Twisted reactor for managing events--the challenge of integrating Twisted's powerful capabilities into an existing event-driven program (eg, any GUI app) is entirely omitted. Furthermore, the book ends somewhat suddenly; I would have welcomed a "Great! What now?" sort of wrap-up that would provide a guidepost to more advanced topics.
These warts are quite forgiveable, however, and will hopefully be corrected in a future revision. The book is clean, friendly, and clear, and provides a nice entry into the world of Twisted. We are neither talked down to, nor beaten into submission by overly dense, inscrutable prose. For this printing, keep the errata handy to quickly resolve any issues with the example code (and submit anything new that you find). While the topics might be considered limited, it's clear that what's here is the tip of the iceberg; you can use these familiar topics to try to sell your boss on Twisted, and then your imagination is the only limit to what you can do. Since my initial experience with Twisted, the core documentation has improved immensely, but it's even stronger if you're already familiar with what's presented here; start with this book, then dive on into the online docs, and you'll be a Twisted guru in no time.
- Mood: geeky