power, and may even not conform to current HTML standards. In fact, much of the
material added in later editions of this book reflects recent technology shifts in this
domain.
Given such a large and dynamic field, this part of the book does not even pretend to
be a complete look at the server-side scripting domain. That is, you should not take
this text to be a final word on the subject. To become truly proficient in this area, you
should also expect to spend some time studying other texts for additional
webmaster-y details and techniques—for example, Chuck Musciano and Bill
Kennedy’s HTML & XHTML: The Definitive Guide (O’Reilly).
The good news is that here you will explore the core ideas behind server-side program-
ming, meet Python’s CGI tool set, and learn enough to start writing substantial websites
of your own in Python. This knowledge should apply to wherever the Web or you head
next.
What’s a Server-Side CGI Script?
Simply put, CGI scripts implement much of the interaction you typically experience
on the Web. They are a standard and widely used mechanism for programming web-
based systems and website interaction, and they underlie most of the larger web
development models.
There are other ways to add interactive behavior to websites with Python, both on the
client and the server. We briefly met some such alternatives near the start of Chap-
ter 12. For instance, client-side solutions include Jython applets, RIAs such as Silver-
light and pyjamas, Active Scripting on Windows, and the emerging HTML 5 standard.
On the server side, there are a variety of additional technologies that build on the basic
CGI model, such as Python Server Pages, and web frameworks such as Django, App
Engine, CherryPy, and Zope, many of which utilize the MVC programming model.
By and large, though, CGI server-side scripts are used to program much of the activity
on the Web, whether it’s programmed directly or partly automated by frameworks and
tools. CGI scripting is perhaps the most primitive approach to implementing websites,
and it does not by itself offer the tools that are often built into larger frameworks such
as state retention, database interfaces, and reply templating. CGI scripts, however, are
in many ways the simplest technique for server-side scripting. As a result, they are an
ideal way to get started with programming on the server side of the Web. Especially for
simpler sites that do not require enterprise-level tools, CGI is sufficient, and it can be
augmented with additional libraries as needed.
The Script Behind the Curtain
Formally speaking, CGI scripts are programs that run on a server machine and adhere
to the Common Gateway Interface—a model for browser/server communications,
1126 | Chapter 15: Server-Side Scripting