summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2000-04-04 23:12:50 +0000
committerbwarsaw2000-04-04 23:12:50 +0000
commit97d0cd927eb108d6970fa7e973e8be89c439c2eb (patch)
treeff3c814fe7000725a87c2625e4e3e5089ad9a485
parent85ff1df49be81af31a33f466ac7ab424fe00cad8 (diff)
downloadmailman-97d0cd927eb108d6970fa7e973e8be89c439c2eb.tar.gz
mailman-97d0cd927eb108d6970fa7e973e8be89c439c2eb.tar.zst
mailman-97d0cd927eb108d6970fa7e973e8be89c439c2eb.zip
Some meager consistency in handling errors when trying to open the
mailing list. In all cases, catch the base exception class MMListError, and output HTML indicating the specified list doesn't exist. A more detail message gets printed to logs/error (the str() of the actual exception details). Also: admin.py - Don't catch MMBadConfigError around mlist.parse_matching_header_opt() since this method doesn't ever raise that exception. Actually, that exception isn't raised anywhere in Mailman, so it's been removed.
-rw-r--r--Mailman/Cgi/admin.py14
-rw-r--r--Mailman/Cgi/admindb.py12
-rw-r--r--Mailman/Cgi/edithtml.py9
-rw-r--r--Mailman/Cgi/handle_opts.py11
-rw-r--r--Mailman/Cgi/listinfo.py8
-rw-r--r--Mailman/Cgi/options.py8
-rw-r--r--Mailman/Cgi/private.py12
-rw-r--r--Mailman/Cgi/roster.py18
-rw-r--r--Mailman/Cgi/subscribe.py7
9 files changed, 55 insertions, 44 deletions
diff --git a/Mailman/Cgi/admin.py b/Mailman/Cgi/admin.py
index c6463f985..bb692374c 100644
--- a/Mailman/Cgi/admin.py
+++ b/Mailman/Cgi/admin.py
@@ -18,6 +18,7 @@
"""
+import sys
import os
import cgi
import string
@@ -65,8 +66,9 @@ def main():
listname = string.lower(parts[0])
try:
mlist = MailList.MailList(listname)
- except (Errors.MMUnknownListError, Errors.MMListNotReady):
- FormatAdminOverview(error="List <em>%s</em> not found." % listname)
+ except Errors.MMListError, e:
+ FormatAdminOverview('No such list <em>%s</em>' % listname)
+ sys.stderr.write('No such list "%s": %s\n' % (listname, e))
return
try:
if len(parts) == 1:
@@ -141,13 +143,7 @@ def main():
return
if cgi_data.has_key('bounce_matching_headers'):
- try:
- pairs = mlist.parse_matching_header_opt()
- except Errors.MMBadConfigError, line:
- AddErrorMessage(doc,
- 'Warning: bad matching-header line'
- ' (does it have the colon?)<ul> %s </ul>',
- line)
+ pairs = mlist.parse_matching_header_opt()
if not mlist.digestable and len(mlist.GetDigestMembers()):
AddErrorMessage(doc,
diff --git a/Mailman/Cgi/admindb.py b/Mailman/Cgi/admindb.py
index 52d8d7646..fb4cd256f 100644
--- a/Mailman/Cgi/admindb.py
+++ b/Mailman/Cgi/admindb.py
@@ -17,14 +17,17 @@
"""Produce and process the pending-approval items for a list."""
import os
+import sys
import string
import types
import cgi
from errno import ENOENT
-from Mailman import Utils, MailList, Errors
-from Mailman.htmlformat import *
from Mailman import mm_cfg
+from Mailman import Utils
+from Mailman import MailList
+from Mailman import Errors
+from Mailman.htmlformat import *
@@ -60,8 +63,9 @@ def main():
# now that we have the list name, create the list object
try:
mlist = MailList.MailList(listname)
- except (Errors.MMUnknownListError, Errors.MMListNotReady):
- handle_no_list(doc, 'No such list: <tt>%s</tt><p>' % listname)
+ except Errors.MMListError, e:
+ handle_no_list(doc, 'No such list <em>%s</em><p>' % listname)
+ sys.stderr.write('No such list "%s": %s\n' % (listname, e))
return
#
# now we must authorize the user to view this page, and if they are, to
diff --git a/Mailman/Cgi/edithtml.py b/Mailman/Cgi/edithtml.py
index 8f9e54b4b..70c5da036 100644
--- a/Mailman/Cgi/edithtml.py
+++ b/Mailman/Cgi/edithtml.py
@@ -16,11 +16,13 @@
"""Script which implements admin editing of the list's html templates."""
+import sys
import os
import cgi
import string
-from Mailman import Utils, MailList
+from Mailman import Utils
+from Mailman import MailList
from Mailman.htmlformat import *
from Mailman.HTMLFormatter import HTMLFormatter
from Mailman import Errors
@@ -48,9 +50,10 @@ def main():
listname = string.lower(parts[0])
try:
mlist = MailList.MailList(listname, lock=0)
- except (Errors.MMUnknownListError, Errors.MMListNotReady):
- doc.AddItem(Header(2, "%s : No such list" % listname))
+ except Errors.MMListError, e:
+ doc.AddItem(Header(2, 'No such list <em>%s</em>' % listname))
print doc.Format(bgcolor='#ffffff')
+ sys.stderr.write('No such list "%s": %s\n' % (listname, e))
return
# get the list._template_dir attribute
diff --git a/Mailman/Cgi/handle_opts.py b/Mailman/Cgi/handle_opts.py
index a0cf7a120..eb8ac5456 100644
--- a/Mailman/Cgi/handle_opts.py
+++ b/Mailman/Cgi/handle_opts.py
@@ -21,9 +21,11 @@ import os
import string
import cgi
-from Mailman.htmlformat import *
-from Mailman import Utils, MailList, Errors
from Mailman import mm_cfg
+from Mailman import Utils
+from Mailman import MailList
+from Mailman import Errors
+from Mailman.htmlformat import *
@@ -65,10 +67,11 @@ def main():
try:
mlist = MailList.MailList(listname)
- except (Errors.MMUnknownListError, Errors.MMListNotReady):
+ except Errors.MMListError, e:
doc.AddItem(Header(2, "Error"))
- doc.AddItem(Bold("%s: No such list." % listname))
+ doc.AddItem(Bold('No such list <em>%s</em>' % listname))
print doc.Format(bgcolor="#ffffff")
+ sys.stderr.write('No such list "%s": %s\n' % (listname, e))
return
try:
diff --git a/Mailman/Cgi/listinfo.py b/Mailman/Cgi/listinfo.py
index 3dcbfb541..17db20d62 100644
--- a/Mailman/Cgi/listinfo.py
+++ b/Mailman/Cgi/listinfo.py
@@ -19,12 +19,13 @@
# No lock needed in this script, because we don't change data.
+import sys
import os
import string
+from Mailman import mm_cfg
from Mailman import Utils
from Mailman import MailList
-from Mailman import mm_cfg
from Mailman import Errors
from Mailman.htmlformat import *
@@ -45,8 +46,9 @@ def main():
listname = string.lower(parts[0])
try:
mlist = MailList.MailList(listname, lock=0)
- except (Errors.MMUnknownListError, Errors.MMListNotReady):
- FormatListinfoOverview(error="List <em>%s</em> not found." % listname)
+ except Errors.MMListError, e:
+ FormatListinfoOverview('No such list <em>%s</em>' % listname)
+ sys.stderr.write('No such list "%s": %s\n' % (listname, e))
return
FormatListListinfo(mlist)
diff --git a/Mailman/Cgi/options.py b/Mailman/Cgi/options.py
index 723178f84..3fc5faa1e 100644
--- a/Mailman/Cgi/options.py
+++ b/Mailman/Cgi/options.py
@@ -25,12 +25,13 @@ unobscured ids as well.
# We don't need to lock in this script, because we're never going to change
# data.
+import sys
import os
import string
+from Mailman import mm_cfg
from Mailman import Utils
from Mailman import MailList
-from Mailman import mm_cfg
from Mailman import Errors
from Mailman.htmlformat import *
@@ -57,10 +58,11 @@ def main():
# open list
try:
mlist = MailList.MailList(listname, lock=0)
- except (Errors.MMUnknownListError, Errors.MMListNotReady):
+ except Errors.MMListError, e:
doc.AddItem(Header(2, "Error"))
- doc.AddItem(Bold("%s: No such list." % listname ))
+ doc.AddItem(Bold('No such list <em>%s</em>' % listname))
print doc.Format()
+ sys.stderr.write('No such list "%s": %s\n' % (listname, e))
return
# Sanity check the user
diff --git a/Mailman/Cgi/private.py b/Mailman/Cgi/private.py
index f0c206916..750e2d8bd 100644
--- a/Mailman/Cgi/private.py
+++ b/Mailman/Cgi/private.py
@@ -104,7 +104,7 @@ def main():
doc.AddItem(Header(3, "You must specify a list."))
print doc.Format(bgcolor="#FFFFFF")
sys.exit(0)
- list_name = string.lower(list_info[0])
+ listname = string.lower(list_info[0])
# If it's a directory, we have to append index.html in this script. We
# must also check for a gzipped file, because the text archives are
@@ -117,14 +117,14 @@ def main():
true_filename = true_filename + '.gz'
try:
- listobj = MailList.MailList(list_name, lock=0)
- except Errors.MMUnknownListError:
- listobj = None
- if not (listobj and listobj._ready):
- msg = "%s: No such list." % list_name
+ listobj = MailList.MailList(listname, lock=0)
+ listobj.IsListInitialized()
+ except Errors.MMListError, e:
+ msg = 'No such list <em>%s</em>' % listname
doc.SetTitle("Private Archive Error - %s" % msg)
doc.AddItem(Header(2, msg))
print doc.Format(bgcolor="#FFFFFF")
+ sys.stderr.write('No such list "%s": %s\n' % (listname, e))
sys.exit(0)
form = cgi.FieldStorage()
diff --git a/Mailman/Cgi/roster.py b/Mailman/Cgi/roster.py
index 66f3d1da5..cdb9dfbcb 100644
--- a/Mailman/Cgi/roster.py
+++ b/Mailman/Cgi/roster.py
@@ -79,7 +79,6 @@ def main():
def get_list():
"Return list or bail out with error page."
-
list_info = []
try:
list_info = Utils.GetPathPieces(os.environ['PATH_INFO'])
@@ -88,20 +87,21 @@ def get_list():
if len(list_info) != 1:
error_page("Invalid options to CGI script.")
sys.exit(0)
- list_name = string.lower(list_info[0])
+ listname = string.lower(list_info[0])
try:
- list = MailList.MailList(list_name, lock = 0)
- except Errors.MMUnknownListError:
- error_page("%s: No such list.", list_name)
- sys.exit(0)
- if not list._ready:
- error_page("%s: No such list.", list_name)
+ mlist = MailList.MailList(listname, lock=0)
+ mlist.IsListInitialized()
+ except Errors.MMListError, e:
+ error_page('No such list <em>%s</em>' % listname)
+ sys.stderr.write('No such list "%s": %s\n' % (listname, e))
sys.exit(0)
- return list
+ return mlist
+
def error_page(errmsg, *args):
print apply(error_page_doc, (errmsg,) + args).Format()
+
def error_page_doc(errmsg, *args):
"""Produce a simple error-message page on stdout and exit.
diff --git a/Mailman/Cgi/subscribe.py b/Mailman/Cgi/subscribe.py
index 618e6f3ca..42593d2c9 100644
--- a/Mailman/Cgi/subscribe.py
+++ b/Mailman/Cgi/subscribe.py
@@ -49,12 +49,13 @@ def main():
listname = string.lower(parts[0])
try:
mlist = MailList.MailList(listname)
- except (Errors.MMUnknownListError, Errors.MMListNotReady):
+ mlist.IsListInitialized()
+ except Errors.MMListError, e:
doc.AddItem(Header(2, "Error"))
- doc.AddItem(Bold("%s: No such list." % listname))
+ doc.AddItem(Bold('No such list <em>%s</em>' % listname))
print doc.Format(bgcolor="#ffffff")
+ sys.stderr.write('No such list "%s": %s\n' % (listname, e))
return
-
try:
process_form(mlist, doc)
finally: