MailSenderClass.smtpPassword = None # try again; 3.0/4E: not on self
sendingBusy.decr()
def askSmtpPassword(self):
"""
get password if needed from GUI here, in main thread;
caveat: may try this again in thread if no input first
time, so goes into a loop until input is provided; see
pop paswd input logic for a nonlooping alternative
"""
password = ''
while not password:
prompt = ('Password for %s on %s?' %
(self.smtpUser, self.smtpServerName))
password = popuputil.askPasswordWindow(appname, prompt)
return password
class ReplyWindow(WriteWindow):
"""
customize write display for replying
text and headers set up by list window
"""
modelabel = 'Reply'
class ForwardWindow(WriteWindow):
"""
customize reply display for forwarding
text and headers set up by list window
"""
modelabel = 'Forward'
messagecache: Message Cache Manager
The class in Example 14-5 implements a cache for already loaded messages. Its logic is
split off into this file in order to avoid further complicating list window implementa-
tions. The server list window creates and embeds an instance of this class to interface
with the mail server and to keep track of already loaded mail headers and full text. In
this version, the server list window also keeps track of mail fetches in progress, to avoid
attempting to load the same mail more than once in parallel. This task isn’t performed
here, because it may require GUI operations.
Example 14-5. PP4E\Internet\Email\PyMailGui\messagecache.py
"""
##############################################################################
manage message and header loads and context, but not GUI;
a MailFetcher, with a list of already loaded headers and messages;
the caller must handle any required threading or GUI interfaces;
3.0 change: use full message text Unicode encoding name in local
mailconfig module; decoding happens deep in mailtools, when a message
PyMailGUI Implementation| 1095