This section presents the source code of the utility modules imported and used by the page scripts shown earlier. As installed, all of these modules live in the same directory as the CGI scripts, to make imports simple—they are found in the current working directory. There aren’t any new screenshots to see here because these are utilities, not CGI scripts. 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 listed previously. See earlier in this chapter for additional details not repeated here.
When running PyMailCGI out of its own directory in the book examples distribution tree, it relies on a number of external modules that are potentially located elsewhere. Because all of these are accessible from the PP4E package root, they can be imported with dotted-path names as usual, relative to the root. In case this setup ever changes, though, the module in Example 16-10 encapsulates the location of all external dependencies; if they ever move, this is the only file that must be changed.
Example 16-10. PP4E\Internet\Web\PyMailCgi\cgi-bin\externs.py
""" isolate all imports of modules that live outside of the PyMailCgi directory, so that their location must only be changed here if moved; we reuse the mailconfig settings that were used for pymailgui2 in ch13; PP4E/'s container must be on sys.path to use the last import here; """ import ...