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

(yzsuai) #1

administration. In this part of the book, we will take an honest look at the Net’s trade-
offs as they arise and explore examples which illustrate the advantages of both web and
nonweb architectures. In fact, the larger PyMailGUI and PyMailCGI examples we’ll
explore are intended in part to serve this purpose.


The Internet is also considered by many to be something of an ultimate proof of concept
for open source tools. Indeed, much of the Net runs on top of a large number of such
tools, such as Python, Perl, the Apache web server, the sendmail program, MySQL, and
Linux.* Moreover, new tools and technologies for programming the Web sometimes
seem to appear faster than developers can absorb them.


The good news is that Python’s integration focus makes it a natural in such a hetero-
geneous world. Today, Python programs can be installed as client-side and server-side
tools; used as applets and servlets in Java applications; mixed into distributed object
systems like CORBA, SOAP, and XML-RPC; integrated into AJAX-based applications;
and much more. In more general terms, the rationale for using Python in the Internet
domain is exactly the same as in any other—Python’s emphasis on quality, productiv-
ity, portability, and integration makes it ideal for writing Internet programs that are
open, maintainable, and delivered according to the ever-shrinking schedules in this
field.


Running Examples in This Part of the Book


Internet scripts generally imply execution contexts that earlier examples in this book
have not. That is, it usually takes a bit more to run programs that talk over networks.
Here are a few pragmatic notes about this part’s examples, up front:



  • You don’t need to download extra packages to run examples in this part of the
    book. All of the examples we’ll see are based on the standard set of Internet-related
    modules that come with Python and are installed in Python’s library directory.

  • You don’t need a state-of-the-art network link or an account on a web server to
    run the socket and client-side examples in this part. Although some socket exam-
    ples will be shown running remotely, most can be run on a single local machine.
    Client-side examples that demonstrate protocol like FTP require only basic Inter-
    net access, and email examples expect just POP and SMTP capable servers.

  • You don’t need an account on a web server machine to run the server-side scripts
    in later chapters; they can be run by any web browser. You may need such an
    account to change these scripts if you store them remotely, but not if you use a
    locally running web server as we will in this book.



  • There is even a common acronym for this today: LAMP, for the Linux operating system, the Apache web
    server, the MySQL database system, and the Python, Perl, and PHP scripting languages. It’s possible, and
    even very common, to put together an entire enterprise-level web server with open source tools. Python users
    would probably also like to include systems like Zope, Django, Webware, and CherryPy in this list, but the
    resulting acronym might be a bit of a stretch.


“Tune In, Log On, and Drop Out” | 775
Free download pdf