PyATL Book Club on O’Reilly

Marsee Henon from O’Reilly recently interviewed a couple of us
about the Atlanta-area Python Users’ Group Book Club. She asked some
good questions, and although I’m not entirely comfortable with the group
being characterized as an “O’Reilly” book club, O’Reilly does offer us a
lot of support (esp. free books) so I guess I shouldn’t complain.

If you’re interested in participating in a technical book club, you
don’t have to live in or even near, Atlanta to join ours. Head over to and join the Google Group we have set up for
our discussions.

Book Review: RESTful Web Services

As part of the Atlanta Python Users’ Group Book Club, I received a
copy of RESTful Web Services written by Leonard Richardson and Sam
Ruby, and published by O’Reilly Media. When we started the book club,
this was the first book I suggested we read. I had previously studied
some material on various blogs discussing REST, but I wanted a clear
description and more specific examples. The book provided both, and I
highly recommend reading it before planning your next web development


Unlike many such books, RESTful does not depend on a single
programming language for examples. Much of the code is Ruby, but Python
and Java make up a respectable proportion of the material as well. Since
I was primarily interested in the design principles and “theory”, I did
not try to run any of the sample code myself. Others in the book club
have, so check the forum for more details if you are interested in
that aspect of the book.

The outline of the book follows a well thought-out progression of
topics from basic “programmable web” concepts to in-depth discussion of
Roy Fielding’s Representational State Transfer (REST) ideas and then
Resource Oriented Architecture (ROA), a natural extension of REST.
Intermediate chapters include discussions of best-of-breed tools for web
development and copious example code.


Chapter 1 is a foundation chapter for the remainder of the book. It
describes how the HTTP protocol works and breaks down the different
architectural styles discussed in the remaining chapters (REST, RPC, and
REST-RPC hybrid). The theme of this chapter, and perhaps the entire
book, is that “the human web is on the programmable web”. If something
is on the web, it is a service.

Chapter 2 introduces the concepts necessary to implement clients using
web services. The easily digestible example code (in several languages)
implements a client for the bookmarking service.
Bookmarks are an excellent choice for an example program, since the
information being managed is straightforward and everyone understands
the concept, even if they have never used directly. Chapter
2 also includes recommendations for client tools and libraries for
common languages. Basic HTTP access, JSON parsers, XML parsers
(including details about DOM, SAX, and pull-style parsers and when each
is appropriate), and WADL libraries are discussed, with best-of-breed
options presented for each language.

In chapter 3, the authors use Amazon’s S3 service design to point out
features of the REST architecture which make it different from RPC-style
APIs. The complexity of the examples increases to match the requirements
of the service, including advanced authentication techniques.

Resource Oriented Architecture, introduced in Chapter 4 and discussed
in an extended design example used through chapters 5 and 6, is perhaps
the most interesting part of the book. ROA is a set of design principles
which encourage you to think about your service in a specific way to
enable REST APIs. The principles are:

Descriptive URIs
URIs should convey meaning
Expose all information via URLs
The client maintains the application state so the server does not
have to.
Resources can have multiple representations, based on format, level
of detail, language, and other criteria
Link between related resources explicitly within the
representations, so the client does not have to know how to build
Uniform Interface
Use the HTTP methods (GET, PUT, POST, DELETE) as designed

To illustrate these principles, in chapters 5 and 6 the authors build
a web mapping service, similar to Google Maps. This detailed example
also serves as a way to introduce their ROA development process.

  1. Identify the data set to be managed by the service.
  2. Split up that data into resources.
  3. Name each resource with a URI.
  4. Expose a subset of the uniform interface for each resource,
    depending on what makes sense and what features are to be supported.
  5. Design representations to be passed from client to server.
  6. Design representations to be passed from server to client.
  7. Include links to other resources.
  8. Consider a typical course of events, to ensure completeness.
  9. Consider error conditions, to identify the HTTP response codes to be

Chapter 7 includes the implementation of a bookmarking service similar
to The sample code uses Ruby extensively, and it was a
little more advanced than what I was prepared to absorb without a Ruby
primer. One important point made in the prose of the chapter is that
code frameworks may constrain your design by making certain choices for
implementation easier or harder.

Chapter 8 is a summary of the REST and ROA principles discussed in the
earlier chapters, and is an excellent reference once you’ve finished
reading the whole book. It is also suitable as a “Cliff’s Notes” version
of the material, if you don’t have time to read everything. If you want
to review the book before reading it, go to the book store and take a
look at this chapter.

While chapter 2 covered client implementation techniques, chapter 9 is
a survey of tools and aspects of web service implementations in
different languages. It covers topics such as XHTML, HTML5,
micro-formats, Atom, JSON, RDF, control flow patterns, and WSDL.

In chapter 10, the authors give an extensive comparison of ROA and
“Big Web Services” to argue that ROA is simpler, requires fewer tools,
and can even be more interoperable.

Chapter 11 is the requisite “How to use this with AJAX” chapter.
And the book wraps up in chapter 12 with a discussion of frameworks
for doing RESTful development in multiple languages. The coverage of
Django includes a dispatcher that decides how to handle the request
based on the HTTP method invoked.


Before reading “RESTful Web Services”, I had a somewhat cloudy notion
of REST and how to apply it. The book clarified what REST is and how to
apply it. It also offered an invaluable concrete process to follow when
implementing a web service using REST and ROA principles. I expect my
copy to see a lot of use and become dog-eared as I refer back to it

PyATL Book Club

The Atlanta Python Users’ Group runs an online book club. We encourage
all Atlanta area Python developers to check the schedule on and come down to a meeting. Anyone is free to join and
participate. For more reviews by members of the book club, check out
the forums or our Reviews List.

Book Review: CherryPy Essentials

Originally published on my blog, 10 May 2007

A little over a week ago I received a review copy of Sylvain
Hellegouarch’s new book, CherryPy Essentials, published through
Packt Publishing. The timing couldn’t have been better, since we
have begun investigating Python web application frameworks at work for
a new project. From previous work I have done with TurboGears, I knew
that CherryPy was a contender, so I was definitely interested to see
what version 3 had to offer. Sylvain’s book is is a good starting
point for the information I wanted.


CherryPy Essentials is a fairly short book (251 pages), especially
given the breadth of topics it covers. It could easily have been 2-3
times as long, if the author was wordy or repetitive, but the concise
writing style means that there is a lot of good information packed
into this short volume.

The outline is fairly typical for tech books:

  • What is this thing and why do I care? – chapter 1
  • How do I get it? – chapter 2
  • What can it do? – chapters 3-4
  • Build an example app – chapters 5-7
  • Advanced topics – chapters 8-10

The real substance of the book begins with chapter 3, which gives an
overview of CherryPy. It includes a moderately sized introductory
application which lets different authors post notes on a page. The
sample code includes embedded comments and is used as a basis for a
brief description of how CherryPy decides what to do when an HTTP
request is received.

CherryPy comes with a host of modules to make building your
application easier. The coverage given these modules in the “Library”
section of chapter 3 probably does not do them justice. The author
clearly states that his intent is not to create a reference guide, but
I would have liked to see this section pulled out into its own chapter
and expanded, possibly combined with the Tools list in chapter 4.

The more in-depth discussion of CherryPy in chapter 4 includes
instructions for running multiple HTTP servers; various mechanisms for
dispatching URLs to Python functions; serving static content; hooking
into the core to add your own middleware (or “Tools” in
CherryPy-parlance); and WSGI support. The same chapter also includes a
description and concise example of how to use each Tool provided in
the CherryPy core distribution, following a format not unlike the one
I use for my Python Module of the Week series.

Chapters 5-7 discuss the design and development of a photo blog
application, which is small enough for the reader to follow but large
enough to delve into the details of how to build a real application
with CherryPy. The presentation begins with the data model, then
covers web services and user interface topics.

Some of chapter 5, which discusses working with databases, is
unfocused and includes sections on topics such as backgrounds on
database types and object-relational mapping libraries not actually
used in the example applications. This material could have been
eliminated without serious loss. It is interesting, but it detracts a
bit from the overall coherence of this book. Once he selects the
Dejavu ORM, the discussion refocuses and covers the mechanics of using
that library to store and retrieve data.

Chapter 6 provides an excellent discussion of web services, REST, URL
design, and the Atom publishing protocol. These were perhaps the most
interesting sections in the book. The author clearly has a great deal
of experience to share on these topics. I hope there is another book
coming soon with a greater examination of these topics.

The coverage of presentation layer topics in chapter 7 begins with a
brief history of HTML, up to the development of DHTML. Then the Kid
templating language is introduced (thankfully without a comprehensive
survey of all available Python templating languages :-). The UI for
the example application is fairly simple, so only basic Kid features
are really covered, but that is enough. The more complex DHTML work is
handled by Mochikit, introduced here and used more extensively in
chapter 8, which is devoted to Ajax.

The last 2 chapters of the book cover topics too frequently left out
of other books: Testing and Deployment. The chapter on testing
presents several tools which integrate well with CherryPy for
automated testing of different aspects of your application, including
webtest for unit testing, FunkLoad for load testing, and Selenium for
UI testing. I had never seen these tools before, and the descriptions
and examples were enough to make me add them to my “to be researched”

The final chapter covers deployment options for moving a CherryPy app
into production. Options for using Apache, lighthttpd, WSGI, and SSL
are covered, but no definitive “best practice” is suggested. I suppose
the final choice should be made on more variables than could really be
covered, but I would have liked to see clear guidelines for making a
decision about which configuration to use in different situations.

Third-party Tools

Any good, modern, open source project does not stand alone, and
CherryPy is no exception. “CherryPy Essentials” makes it clear that
integrating with third-party tools is an important part of the design
for CherryPy. Tools covered include:

Other tools are also mentioned, but covered in less detail.


CherryPy Essentials packs a surprising amount of information into a
small space. The coverage is not exceptionally deep in any one area,
but is fairly complete. The sample code is consistent and easy to
read. The book is full of useful and interesting information and,
while it occasionally suffers from disjoint flow, I can definitely
recommend it to any Python programmer interested in the future of
CherryPy development, and web technologies in general.

Special thanks to Ms. PyMOTW for proof reading this post for me.