⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usermailpass.py

📁 python web programming 部分
💻 PY
字号:
#! python
#
# $Workfile: UserMailPass.py $ $Revision: 3 $
# $Date: 9/12/01 7:59p $ $Author: Sholden $
#
import User

from Params import SITENAME, MAILHOST, WEBMASTER
import smtplib
import mx.DateTime as mxdt
import mx.DateTime.ARPA as arpa

class Page(User.Page):
    """Send the user an email containing password.

    Note that we should NOT store the user data in the session, as they typically
    arrive at this point after an authentication failure.
    """
    def Body(self):
        try:
            username = self.session._auth["PythonTeach"]["email"]
        except KeyError:
            return """
                <P>You have not yet attempted to use any restricted
                area of the site, so I do not know where to send your
                password. Please <A HREF="mailto:%s">email us</A>
                to let us know the problem you are experiencing.</P>
                """ % WEBMASTER
        udata = User.qStud(username)
        if not len(udata):
            return """
                <P>Sorry, we do not appear to be able to find any
                record of your email address in our database.</P>
                <P>Please <A HREF="mailto:%s">email us</A>
                explaining the situation, and we will
                attempt to resolve the issue.</P>
                """ % WEBMASTER
        udata = udata[0]
        dt = arpa.str(mxdt.now())
        msg = """Date: %s
Subject: Your PythonTeach Account Password
From: %s
To: %s

We regret that you have been temporarily unable to
access the PythonTeach site. Please find below the
details you wil need to start using your account
again.

    Username: %s
    Password: %s

Please make a record of these details.

Sincerely
PythonTeach
""" % (dt, WEBMASTER, udata.StdEmail, udata.StdEmail, udata.StdPasswd)
        try:
            smtp = smtplib.SMTP(MAILHOST)
            result = smtp.sendmail(WEBMASTER, [udata.StdEmail], msg)
            smtp.quit()
            return """
                <P>Your request has been processed. You should shortly
                receive an email reminding you of your account details.
                Thank you for using PythonTeach.</P>
                """
        except smtplib.SMTPException:
            return """
                <P>Sorry, outhoing email is temporarily disabled.</P>
                <P>Please <A HREF="mailto:%s">email us</A>
                explaining the situation, and we will
                attempt to resolve the issue.</P>
                <P>If you do not receive a reply, you should
                try other means of contact listed elsewhere
                on this site.</P>
                """ % WEBMASTER

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -