superclass. The window subclasses mostly just customize the superclass to map mail
Load and Delete calls to the server or a local file.
List windows are created on program startup (the initial server window, and possible
save-file windows for command-line options), as well as in response to Open button
actions in existing list windows (for opening new save-file list windows). See the Open
button’s callback in this example for initiation code.
Notice that the basic mail processing operations in the mailtools package from Chap-
ter 13 are mixed into PyMailGUI in a variety of ways. The list window classes in
Example 14-3 inherit from the mailtools mail parser class, but the server list window
class embeds an instance of the message cache object, which in turn inherits from the
mailtools mail fetcher. The mailtools mail sender class is inherited by message view
write windows, not list windows; view windows also inherit from the mail parser.
This is a fairly large file; in principle it could be split into three files, one for each class,
but these classes are so closely related that it is handy to have their code in a single file
for edits. Really, this is one class, with two minor extensions.
Example 14-3. PP4E\Internet\Email\PyMailGui\ListWindows.py
"""
###############################################################################
Implementation of mail-server and save-file message list main windows:
one class per kind. Code is factored here for reuse: server and file
list windows are customized versions of the PyMailCommon list window class;
the server window maps actions to mail transferred from a server, and the
file window applies actions to a local file.
List windows create View, Write, Reply, and Forward windows on user actions.
The server list window is the main window opened on program startup by the
top-level file; file list windows are opened on demand via server and file
list window "Open". Msgnums may be temporarily out of sync with server if
POP inbox changes (triggers full reload here).
Changes here in 2.1:
-now checks on deletes and loads to see if msg nums in sync with server
-added up to N attachment direct-access buttons on view windows
-threaded save-mail file loads, to avoid N-second pause for big files
-also threads save-mail file deletes so file write doesn't pause GUI
TBD:
-save-mail file saves still not threaded: may pause GUI briefly, but
uncommon - unlike load and delete, save/send only appends the local file.
-implementation of local save-mail files as text files with separators
is mostly a prototype: it loads all full mails into memory, and so limits
the practical size of these files; better alternative: use 2 DBM keyed
access files for hdrs and fulltext, plus a list to map keys to position;
in this scheme save-mail files become directories, no longer readable.
###############################################################################
"""
from SharedNames import * # program-wide global objects
1068 | Chapter 14: The PyMailGUI Client