Utility Modules
This section presents the source code
of the utility modules imported and used by the page scripts shown
above. There aren’t any new screen shots to see here, because
these are utilities, not CGI scripts (notice their
.py
extensions). Moreover, these modules
aren’t all that useful to study in isolation, and are included
here primarily to be referenced as you go through the CGI
scripts’ code. See earlier in this chapter for additional
details not repeated here.
External Components
When I install PyMailCgi and other
server-side programs shown in this book, I simply upload the contents
of the Cgi-Web
examples directory on my laptop
to the top-level web directory on my server account
(public_html
). The Cgi-Web
directory also lives on this book’s CD (see http://examples.oreilly.com/python2), a mirror of the one on
my PC. I don’t copy the entire book examples distribution to my
web server, because code outside the Cgi-Web
directory isn’t designed to run on a web server.
When I first
installed PyMailCgi, however, I ran into a problem: it’s
written to reuse modules coded in other parts of the book, and hence
in other directories outside Cgi-Web
. For
example, it reuses the mailconfig
and
pymail
modules we wrote in Chapter 11, but neither lives in the CGI examples
directory. Such external dependencies are usually okay, provided we
use package imports or configure sys.path
appropriately on startup. In the context of CGI scripts, though, what lives on my development machine ...
Get Programming Python, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.