problem about Mailman

Xiao Bing xiao.bing at oztime.com
Wed Nov 1 03:48:14 EST 2000


I modify The subscription script for my request.
like this(msg include some Chinese Charactors.Never mind)
--------------------------------------------------------------------# This
Python Program is wroten by Xiao.Bing
# 2000.11
# oz_subscribe.py
"""Process subscription requests from oz_maillist form."""
import sys
import os
import string
import cgi

from Mailman import Utils
from Mailman import MailList
from Mailman import Errors
from Mailman.htmlformat import *
from Mailman import mm_cfg
from Mailman.Logging.Syslog import syslog

def main():
    doc = Document()
    parts = Utils.GetPathPieces()
    if not parts:
        doc.AddItem(Header(2, "错误"))
        doc.AddItem(Bold('未传送给CGI合法的参数!'))
        print doc.Format(bgcolor="#ffffff")
        return

    listname = string.lower(parts[0])
    try:
        mlist = MailList.MailList(listname)
        mlist.IsListInitialized()
    except Errors.MMListError, e:
        doc.AddItem(Header(2, "错误"))
        doc.AddItem(Bold('没有此邮件列表<em>%s</em>' % listname))
        print doc.Format(bgcolor="#ffffff")
        syslog('error', 'No such list "%s": %s\n' % (listname, e))
        return
    try:
        process_form(mlist, doc)
    finally:
        mlist.Save()
        mlist.Unlock()

def process_form(mlist, doc):
    form = cgi.FieldStorage()
    error = 0
    results = ''

    # Preliminaries done, actual processing of the form input below.

    if not form.has_key("email"):
        error = 1
        results = results + "你必须提供一个有效的Email地址.<br>"
        #
        # define email so we don't get a NameError below
        # with if email == mlist.GetListEmail() -scott
        #
        email = ""
    else:
        email = form["email"].value

    remote = remote_addr()
    if email == mlist.GetListEmail():
        error = 1
        if remote:
            remote = "Web site " + remote
        else:
            remote = "unidentified origin"
        badremote = "\n\tfrom " + remote
        syslog("mischief", "Attempt to self subscribe %s:%s"
               % (email, badremote))
    #    results = results + "You must not subscribe a list to itself!<br>"
      results = results + "不能自订阅邮件列表!<br>"
    #   缺省的文摘发布形式
 digest = mlist.digest_is_default

    if not mlist.digestable:
        digest = 0
    elif not mlist.nondigestable:
        digest = 1

    if not error:
        try:
            if mlist.FindUser(email):
                raise Errors.MMAlreadyAMember, email
            if digest:
                digesting = " digest"
            else:
                digesting = ""
            mlist.AddMember(email, "", digest, remote)
        #
        # check for all the errors that mlist.AddMember can throw
        # options  on the web page for this cgi
        #
        except Errors.MMBadEmailError:
            results = results + ("邮件列表服务器不接受此邮件地址为"
                                 "合法的邮件地址.<p>")
        except Errors.MMListError:
            results = results + ("邮件列表服务器"
                                 "不能接受订阅请求.<p>")
        except Errors.MMSubscribeNeedsConfirmation:
             results = results + ("订阅请求需要得到确认,"
                                  "订阅确认信息将被发往"
                                  "%s. 请注意: "
                                  "如果你不能及时确认,订阅将"
                                  "不能生效!<p>" % email)

        except Errors.MMNeedApproval, x:
            results = results + ("订阅将被<em>延缓</em> "
                                 "因为 %s.  你的请求已经被"
                                 "转发给邮件列表管理员."
                                 "你将收到通知邮件<p>" % x)
        except Errors.MMHostileAddress:
            results = results + ("你的订阅被禁止,由于"
                                 "你给的邮件地址是不可靠的.<p>")
        except Errors.MMAlreadyAMember:
            results = results + "你已经订阅过了!<p>"
        #
        # these shouldn't happen, but if someone's futzing with the cgi
        # they might -scott
        #
        except Errors.MMCantDigestError:
            results = results + \
                      "No one can subscribe to the digest of this list!"
        except Errors.MMMustDigestError:
            results = results + \
                      "This list only supports digest subscriptions!"
        else:
            results = results + \
                      "恭喜你!你已经成功的订阅了 %s 邮件列表.<p>" % \
                      (mlist.real_name)
    PrintResults(mlist, results, doc)



def PrintResults(mlist, results, doc):
    replacements = mlist.GetStandardReplacements()
    replacements['<mm-results>'] = results
    output = mlist.ParseTags('oz_sub_success.html', replacements)
    doc.AddItem(output)
    print doc.Format(bgcolor="#ffffff")



def remote_addr():
    "Try to return the remote addr, or if unavailable, None."
    if os.environ.has_key('REMOTE_HOST'):
        return os.environ['REMOTE_HOST']
    elif os.environ.has_key('REMOTE_ADDR'):
        return os.environ['REMOTE_ADDR']
    else:
        return None
--------------------------------------------------------------------------
I write a simple HTML code to invoke the script.
<form method="POST" action="/mailman/oz_subscribe/oztime_tech">
  <p>Please Input you email addr:  <input type="text" name="email"
size="20"><input type="submit" value="subscribe to" name="subscribe"></p>
</form>
---------------------------------------------------------------------------
oz_subscribe is a CGI program produced by a script(PY) file with same name.
oztime_tech is a MailList name.

But I get a error msg

Bug in Mailman version 2.0rc1

We're sorry, we hit a bug!
Please inform the webmaster for this site of this problem. Printing of
traceback and other system information has been explicitly inhibited, but
the webmaster can find this information in the Mailman error logs.

So I go to see the error log.I found nothing.(Before did these.I simply
cleared all content in the error log file)

Why?Who can help me?





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20001101/28b23cb1/attachment.html>


More information about the Python-list mailing list