Because of the current lack of inbox synchronization error checks in
PyMailCGI, you should not delete mails with it in an important account,
unless you employ one of the solution schemes described or you use
other tools to save mails to be deleted before deletion. Adding state
retention to ensure general inbox synchronization may make an inter-
esting exercise, but would also add more code than we have space for
here, especially if generalized for multiple simultaneous site users.
Utility Modules
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.
External Components and Configuration
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 de-
pendencies; 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 sys
#sys.path.insert(0, r'C:\Users\mark\Stuff\Books\4E\PP4E\dev\Examples')
sys.path.insert(0, r'........') # relative to script dir
import mailconfig # local version
from PP4E.Internet.Email import mailtools # mailtools package
This module simply preimports all external names needed by PyMailCGI into its own
namespace. See Chapter 13 for more on the mailtools package modules’ source code
imported and reused here; as for PyMailGUI, much of the magic behind PyMailCGI is
actually implemented in mailtools.
1276 | Chapter 16: The PyMailCGI Server