August 2006
Intermediate to advanced
1600 pages
51h 46m
English
At this point in our PyMailCGI web interaction, we are viewing an email message (Figure 17-12) that was chosen from the selection list page. On the message view page, selecting an action from the pull-down list and clicking the Next button invokes the script in Example 17-9 on the server to perform a reply, forward, or delete operation for the selected message.
Example 17-9. PP3E\Internet\Web\PyMailCgi\cgi-bin\onViewPageAction.py
#!/usr/bin/python ####################################################################### # On submit in mail view window, action selected=(fwd, reply, delete) # in 2.0, we reuse the mailtools delete logic orig coded for PyMailGUI ####################################################################### import cgi, commonhtml, secret from externs import mailtools, mailconfig from commonhtml import getfield def quotetext(form): """ note that headers come from the prior page's form here, not from parsing the mail message again; that means that commonhtml.viewpage must pass along date as a hidden field """ quoted = '\n-----Original Message-----\n' for hdr in ('From', 'To', 'Date'): quoted = quoted + '%s: %s\n' % (hdr, getfield(form, hdr)) quoted = quoted + '\n' + getfield(form, 'text') quoted = '\n' + quoted.replace('\n', '\n> ') return quoted form = cgi.FieldStorage( ) # parse form or URL data user, pswd, site = commonhtml.getstandardpopfields(form) pswd = secret.decode(pswd) try: if form['action'].value == 'Reply': headers = {'From': ...