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

📄 userentry.py

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

class Page(User.Page):
    """Accept account details from user to create or update database entry.

    This code only handles new accounts for the PythonTeach realm. If a
    user hits some other protected area aby accident we politely solicit
    an email request.
    """
    def Body(self):
        if not self.Realm():    # new user: check realm
            if not self.path:
                return \
                """<P>Sorry, I have to know what type of account
                you want me to create.</P>"""
            if self.path[0] != "PythonTeach":
                return \
                """<P>Sorry. Accounts for the '%s' area of the site can
                only be created by email. You can send your request
                in by <A HREF="mailto:newaccount@holdenweb.com">
                clicking here</A>.""" % self.path[0]
            udata = None
            action = "/UserSignUp/"
            FD = User.buildFD("Please Enter Your Details",
                    "Use the CREATE button to create your account")
            buttons = (("CREATE", 0), )
        else:                   # existing, authenticated PythonTeach user
            action = "/Auth/UserChange/"
            FD = User.buildFD("Current User Details",
                    "Use the CHANGE button to update this data",
                    newkey=0)
            buttons = (("CHANGE", 0), )
            if self.Realm() != "PythonTeach":
                raise Error(500, "Server Error", "", [],
                    errmsg="""Program error: this page should be in the
                        'PythonTeach' realm - please report this to our
                         <A HREF="mailto:%s>webmaster</A>.""" % WEBMASTER)
            try:
                udata = self.session._udata
            except AttributeError:
                username = self.session._auth["PythonTeach"]["email"]
                # must have accessed this row to authenticate for the realm
                # now read it all in and stash it in the session
                udata = User.qStud(username)[0]
                self.session._udata = udata
        self.session._fd = FD
        self.session._secureform = 1
        form = pyforms.FormBuild(FD, "UserForm",
                    action, Width=25,
                    Buttons=buttons,
                    R=udata)
        return form



⌨️ 快捷键说明

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