📄 user.py
字号:
#! python
#
# $Workfile: User.py $ $Revision: 14 $
# $Date: 10/07/01 1:48p $ $Author: Sholden $
#
"""Collect details of new account, and allow changes on existing accounts.
NOTE: THIS CODE ASSUMES that it is in the PythonTeach realm or outside any
realm requiring authentication. The latter location is used to enter new
details. It doesn't make sense to use this for other realms unless they use
the same authentication base as PythonTeach, since we are handling user data!
"""
#
# XXX Note that some of this code might migrate into the pyforms module
#
import pyforms
import Web
import HomePage
from cachequery import CacheQuery
from dtuple import TupleDescriptor, DatabaseTuple
from dbsource import dbsource
from Error import Error
from Params import WEBMASTER
conn = dbsource().conn
cursor = conn.cursor()
def buildFD(comment1, comment2, newkey=1):
if newkey:
emtype = "T"
pwtype = "PP"
else:
emtype = "H"
pwtype = "PPP"
Fdescription = (
["Comment1", comment1, "REM", "+2", ""],
["Comment2", comment2, "REM", "-2", ""],
["StdEmail", "Email", emtype, 50, "R"],
["StdFirstName", "First Name", "T", 25, "R"],
["StdLastName", "Last Name", "T", 25, "R"],
["StdPhone", "Telephone", "T", 25, "R"],
["Comment3", "Remember to set <B>both</B> password fields",
"REM", "-2", ""],
["StdPasswd", "Password", pwtype, 12, "R"],
["StdAddress", "Address", "T", 40, ""],
["StdCity", "City", "T", 25, ""],
["StdState", "State/Province", "T", 15, ""],
["StdPostCode", "Zip/Post Code","T", 10, ""]
)
return Fdescription
StdNames = Web.StdNames
StdNokey = [x for x in StdNames if x != "StdEmail"]
TD = TupleDescriptor([[x] for x in StdNames])
qStud = CacheQuery("Student", StdNames, ("StdEmail", ), conn)
class Page(HomePage.Home):
def Title(self):
return "My PythonTeach"
def Body(self):
udata = self.session._udata
return """
<H3>Welcome back, %s %s</H3>
<P>We are glad to see that you are using the
features of our site. If you need any special
help, please <A HREF="mailto:%s">mail us</A>
to let us know what you want.</P>
""" % (udata.StdFirstName, udata.StdLastName, WEBMASTER)
def PTNav(self):
links = [
("/Auth/UserCheck/", "My Account"),
("/Auth/Secret/", "Members Only")
]
return "\n".join([self.NavLink(p) for p in links])
def getFormData(self):
udata = tuple([self.input[x] for x in StdNames])
udata = DatabaseTuple(TD, udata)
return udata
def RedText(self, t):
return """<FONT COLOR="RED">%s</FONT>""" % t
class Secret(Page):
def Title(self):
return "PythonTeach Authenticated Page"
def Body(self):
return """<P>This page can only be seen by authenticated
members of the PythonTeach realm.</P>"""
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -