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

📄 userupdate.py

📁 python web programming 部分
💻 PY
字号:
#! python
#
# $Workfile: UserUpdate.py $ $Revision: 6 $
# $Date: 10/07/01 1:49p $ $Author: Sholden $
#
import User
from Error import Error

class Page(User.Page):
    """Accept updated user details and update database.

    Allows change of any field except the email address, which is used as
    the primary key and the student identifier -- too many downstream
    problems, so at present this requires manual attention to maintain
    any database relationships.
    """
    def Body(self):
        if self.op != "POST":
            raise Error(405, "Method Not Allowed", errmsg="You can only POST to this page")
        FD = self.getValidForm()
        udata = self.getFormData()
        errors = self.ChkReqd(FD, udata)
        if errors:
            errors = self.RedText("<BR>\r\n".join(errors))
            FD = User.buildFD(self.RedText("Please Correct"), errors, newkey=0)
            form = pyforms.FormBuild(FD, "UserForm",
                        "/SignUp/", Width=25,
                        Buttons=(("UPDATE", 0), ),
                        R=udata)
            self.session._fd = FD
            self.session._secureform = 1
            return form
        sql = "UPDATE Student SET %s WHERE StdEmail=%s" % \
                ", ".join(["%s=%%s" % x for x in User.StdNokey])
        User.cursor.execute(sql, tuple([udata[x] for x in User.StdNokey+["StdEmail"]]))
        User.conn.commit()
        self.session._udata = User.qStud((udata["StdEmail"], ))[0]
        return "<P>We have amended your details. Thank You!</P>"



⌨️ 快捷键说明

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