本文整理汇总了Python中model.User.User.update方法的典型用法代码示例。如果您正苦于以下问题:Python User.update方法的具体用法?Python User.update怎么用?Python User.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User.User
的用法示例。
在下文中一共展示了User.update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import update [as 别名]
def post(self):
validcode = self.get_request("validcode", "")
if "validcode" in self.session:
if validcode != self.session['validcode'] :
self.print_result(False, "ValidCode is incorrect!!")
return
else:
self.print_result(False, "ValidCode is incorrect!!")
return
user = User().getByID(self.userID, False)
if user :
# found it
# send email
activationKey = user.getEncodeStr(str(user.user_login)+"-"+ str(time.time()))
user.user_activation_key = activationKey
if user.update() :
self.print_result(True, "Done")
"""
Send Email to register
"""
msg = self.render_string("email/register.html",activationKey=activationKey, login_user = user.user_login, website_url= self.webroot_url("", True), web_title = self.web_title() )
subject = "["+self.web_title()+"] ReSend Activation Key"
qm = SingleMail.get_instance()
qm.send_email(user.user_email,subject, msg, 'html')
else :
self.print_result(False, "Failed to Update DB")
else:
# find failed
self.print_result(False, "Can not find any record")
示例2: post
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import update [as 别名]
def post(self):
token = self.get_request("Login[token]", None)
newPass = self.get_request("Login[pass]", "")
if token == "" or newPass == "" or len(newPass) < 4:
self.print_result(False, "Incorrect parameters")
return
user = User().getByResetToken(token, False)
if user:
# found it
# send email
user.user_pass = user.getEncodeStr(newPass)
p = dict(
newPass=newPass,
login_user=user.user_login,
admin_email=pyCache.WebOptions['admin_email'],
website_url=self.webroot_url("", True)
)
msg = self.render_string("email/pass_has_changed.html", **p)
subject = "[" + self.web_title() + "] Password Has Change"
user.user_reset_token = ""
user.reset_expired = 0
if user.update():
qm = SingleMail.get_instance()
qm.send_email(user.user_email, subject, msg, 'html')
self.print_result(True, "Done")
else:
self.print_result(False, "Failed to Update DB")
else:
# find failed
self.print_result(False, "Can not find any record via this Email")
示例3: post
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import update [as 别名]
def post(self):
uid = self.get_request("id","")
email = self.get_request("email", "")
user_url = self.get_request("personal_url", "")
displayName = self.get_request("display_name", "")
password = self.get_request("password", "")
role = self.get_request("role","")
status = self.get_int_request("status",0)
if uid =="":
self.print_result(False,"error id is empty")
return
if user_url != "":
tmp = user_url.lower()
if not tmp.startswith("http"):
user_url = "http://"+user_url
if not pyUtility.isURL(user_url):
self.print_result(False, "The Format of URL is wrong!")
return
if email == "":
self.print_result(False, "Email Cannot be blank!")
return
if not pyUtility.isEmail(email):
self.print_result(False, "Email Format is incorrect!")
return
user = User().getByID(uid, False)
if not user:
user.close()
self.print_result(False, "Can not find any record")
return
if user.user_email != email:
"""
Check if email has been taken or not
"""
if not User().isEmailUnique(email, False):
self.print_result(False, "Email Has been used")
return
if not password == "":
newPwd = user.getEncodeStr(password)
if newPwd != user.user_pass:
user.user_pass = newPwd
user.user_email = email
user.user_url = user_url
user.role = pyEnum.GetAccountRole(role)
user.user_status = pyEnum.GetAccountStatusID(status)
user.display_name = displayName
if user.update():
self.print_result(True, "Done", self.webroot_url("admin/users/edit/?id="+uid))
else :
self.print_result(False, "Failed to Update DB")
示例4: get
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import update [as 别名]
def get(self):
tid = self.get_request("id", "")
user = None
if (id != ""):
user = User().getByActivateToken(tid, False)
success = False
login = ""
if not user is None:
user.user_status = 1
user.user_activation_key = ""
login = user.user_login
if user.update():
success = True
self.render("public/activate_account.html", login_name=login, title="Activate Account", isSuccess=success)