[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1

system, which is built upon Zope and delegates site content to its users. Still others use
Python to script Java web applications with Jython (formerly known as JPython)—a
system that compiles Python programs to Java bytecode, exports Java libraries for use
in Python scripts, and allows Python code to serve as web applets downloaded and run
in a browser.


In more recent years, new techniques and systems have risen to prominence in the Web
sphere. For example, XML-RPC and SOAP interfaces for Python have enabled web
service programming; frameworks such as Google App Engine, Django, and Turbo-
Gears have emerged as powerful tools for constructing websites; the XML package in
Python’s standard library, as well as third-party extensions, provides a suite of XML
processing tools; and the IronPython implementation provides seamless .NET/Mono
integration for Python code in much the same way Jython leverages Java libraries.


As the Internet has grown, so too has Python’s role as an Internet tool. Python has
proven to be well suited to Internet scripting for some of the very same reasons that
make it ideal in other domains. Its modular design and rapid turnaround mix well with
the intense demands of Internet development. In this part of the book, we’ll find that
Python does more than simply support Internet scripting; it also fosters qualities such
as productivity and maintainability that are essential to Internet projects of all shapes
and sizes.


Internet Scripting Topics


Internet programming entails many topics, so to make the presentation easier to digest,
I’ve split this subject over the next five chapters of this book. Here’s this part’s chapter
rundown:



  • This chapter introduces Internet fundamentals and explores sockets, the underly-
    ing communications mechanism of the Internet. We met sockets briefly as IPC
    tools in Chapter 5 and again in a GUI use case in Chapter 10, but here we will study
    them in the depth afforded by their broader networking roles.

  • Chapter 13 covers the fundamentals of client-side scripting and Internet protocols.
    Here, we’ll explore Python’s standard support for FTP, email, HTTP, NNTP, and
    more.

  • Chapter 14 presents a larger client-side case study: PyMailGUI, a full-featured
    email client.

  • Chapter 15 discusses the fundamentals of server-side scripting and website con-
    struction. We’ll study basic CGI scripting techniques and concepts that underlie
    most of what happens in the Web.

  • Chapter 16 presents a larger server-side case study: PyMailCGI, a full-featured
    webmail site.


Each chapter assumes you’ve read the previous one, but you can generally skip around,
especially if you have prior experience in the Internet domain. Since these chapters


772 | Chapter 12: Network Scripting

Free download pdf