diff options
| author | klm | 1998-03-30 05:02:55 +0000 |
|---|---|---|
| committer | klm | 1998-03-30 05:02:55 +0000 |
| commit | 511abd34885144b5039b1cc3208c05781384067c (patch) | |
| tree | 22b87bc8901ce75c592fc5b51bb2c2d936f35c14 | |
| parent | cdbb43966a90e6857a46a3a7c2dd2315d8d74371 (diff) | |
| download | mailman-511abd34885144b5039b1cc3208c05781384067c.tar.gz mailman-511abd34885144b5039b1cc3208c05781384067c.tar.zst mailman-511abd34885144b5039b1cc3208c05781384067c.zip | |
Added handling for subscription-list presentation request.
call_script() - Encapsulation of hack to so i could use it for the
mmroster script as well as for the options script.
Using StampedLogger (to logs/error) for stderr, for debugging.
Changed error notices to have a header "Error" and a body describing
the problem.
Added modest module doc string.
| -rwxr-xr-x | cgi/subscribe | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/cgi/subscribe b/cgi/subscribe index a7ef48dd9..90a155ecf 100755 --- a/cgi/subscribe +++ b/cgi/subscribe @@ -1,9 +1,20 @@ #!/usr/local/bin/python -import sys, os, cgi, string -from regsub import gsub + +"""Process listinfo form submission, ie subscriptions or roster requests.""" + +import sys sys.path.append('/home/mailman/mailman/modules') + +import os, cgi, string +from regsub import gsub import mm_utils, maillist, mm_err, mm_message, mm_cfg, htmlformat +try: + sys.stderr = mm_utils.StampedLogger("error", label = 'subscribe', + manual_reprime=1) +except IOError: + pass # Oh well - SOL on redirect, errors show thru. + NEED_CONFIRM_NOTICE = """ A web request for your subscription to the %s mailing list has been received at %s%s @@ -35,20 +46,23 @@ list_info = mm_utils.GetPathPieces(path) list_name = string.lower(list_info[0]) if len(list_info) < 1: - doc.AddItem(htmlformat.Header(2, "Invalid options to CGI script.")) + doc.AddItem(htmlformat.Header(2, "Error")) + doc.AddItem(htmlformat.Bold("Invalid options to CGI script.")) print doc.Format() sys.exit(0) try: list = maillist.MailList(list_name) except: - doc.AddItem(htmlformat.Header(2, "%s: No such list." % list_name )) + doc.AddItem(htmlformat.Header(2, "Error")) + doc.AddItem(htmlformat.Bold("%s: No such list." % list_name )) print doc.Format() sys.exit(0) if not list._ready: - doc.AddItem(htmlformat.Header(2, "%s: No such list." % list_name )) + doc.AddItem(htmlformat.Header(2, "Error")) + doc.AddItem(htmlformat.Bold("%s: No such list." % list_name )) print doc.Format() sys.exit(0) @@ -57,28 +71,39 @@ form = cgi.FieldStorage() error = 0 results = '' -if form.has_key("submitinfo"): +def call_script(which, pathinfo): + "A little bit of a hack to call one of the scripts..." + os.environ['PATH_INFO'] = string.join(pathinfo, '/') + file = os.path.join(mm_cfg.MAILMAN_DIR, 'cgi/%s' % which) + list.Unlock() + execfile(file) + sys.exit(0) + +####### +# Preliminaries done, actual processing of the form input below. + +if form.has_key("SubscriberRoster"): + # Get the roster of subscribers. + call_script('mmroster', [list._internal_name]) + +elif form.has_key("UserOptions"): + # Go to user options section. if not form.has_key("info"): - doc.AddItem(htmlformat.Header(2, - "You must supply your email address.")) + doc.AddItem(htmlformat.Header(2, "Error")) + doc.AddItem(htmlformat.Bold("You must supply your email address.")) doc.AddItem(list.GetMailmanFooter()) print doc.Format() sys.exit(0) - addr = list.FindUser(form['info'].value) - if not addr: - doc.AddItem(htmlformat.Header - (2, "You aren't subscribed to this mailing list under " - "the address you gave.")) + addr = form['info'].value + member = list.FindUser(addr) + if not list.FindUser(addr): + doc.AddItem(htmlformat.Header(2, "Error")) + doc.AddItem(htmlformat.Bold("%s has not subscribed addr <i>%s</i>." + % (list.real_name, addr))) doc.AddItem(list.GetMailmanFooter()) print doc.Format() sys.exit(0) - # A little bit of a hack to call the options script... - os.environ['PATH_INFO'] = '%s/%s' % (list_name,addr) - file = os.path.join(mm_cfg.MAILMAN_DIR, 'cgi/options') - list.Unlock() - execfile(file) - sys.exit(0) - + call_script('options', [list._internal_name, member]) if not form.has_key("email"): error = 1 |
