useractivate.py

来自「python web programming 部分」· Python 代码 · 共 57 行

PY
57
字号
#! python
#
# $Workfile: UserActivate.py $ $Revision: 4 $
# $Date: 9/12/01 7:59p $ $Author: Sholden $
#
import User

from Params import WEBMASTER
from Error import Error
import whrandom
import smtplib
import mx.DateTime as mxdt
import mx.DateTime.ARPA as arpa
import pickle

class Page(User.Page):

    def Body(self):
        if not self.path or len(self.path[0]) != 21:
            raise Error(400, "Bad Request", errmsg="A confirmation number is required.")
        conf = int(self.path[0][7:14])
        sql = "SELECT %s FROM Wannabe WHERE StdConf=%%s" % ", ".join(User.StdNames+["StdOrder"])
        User.cursor.execute(sql, (conf, ))
        r = User.cursor.fetchall()
        if not r:
            return """<P>Unable to find confirmation number %s.</P>
                <P>Either you have already confirmed your membership,
                or you confirmation number is incorrect.</P>
                <P>Please <A HREF="mailto:%s">email us</A> and
                we will try to resolve the problem.</P>""" % \
                            (self.path[0], WEBMASTER)
        sql = "INSERT INTO Student (%s) VALUES (%s)" % (
                            ", ".join(["CrDT"] + User.StdNames),
                            ", ".join("%s"*(len(User.StdNames)+1)))
        User.cursor.execute(sql, (mxdt.DateTimeFromTicks(int(mxdt.now())), )+r[0][:-1])
        User.cursor.execute("DELETE FROM Wannabe WHERE StdConf=%s", (conf, ))
        User.conn.commit()
        self.session._bookings = pickle.loads(r[0][-1])
        if self.session._bookings:
            orderp = """
                <P><B>Click here to <A HREF="/CourseChkOut/">verify your order</A>
                and proceed with confirmation.</B></P>
                """
        else:
            orderp =""
                
        return """
            <H3>User Account Created</H3>
            <P>Thank you. By using this link you have allowed
            us to verify your email address. You can now use
            the restricted functions of the site by logging
            as outlined in your confirmatory email.</P>
            """ + orderp



⌨️ 快捷键说明

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