本文整理汇总了Python中model.User.update方法的典型用法代码示例。如果您正苦于以下问题:Python User.update方法的具体用法?Python User.update怎么用?Python User.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import update [as 别名]
def post(self):
#if self.get_current_user():
# self.redirect("/")
# return
mobile = self.get_argument("mobile", None)
password = self.get_argument("password", None)
apassword = self.get_argument("apassword", None)
vcode = self.get_argument("vcode", None)
sharer = self.get_argument("sharer", None)
realname=self.get_argument("realname",None)
user = User()
user.mobile = mobile
user.realname = realname
user.password = User.create_password(password)
try:
user.validate()
if password and apassword:
if len(password) < 6:
self.flash("请确认输入6位以上新密码")
elif password != apassword:
self.flash("请确认新密码和重复密码一致")
elif len(realname) > 32:
self.flash("微信账号超出长度限制")
elif len(realname) < 2:
self.flash("微信账号太短")
else:
#if UserVcode.select().where((UserVcode.mobile == mobile) & (UserVcode.vcode == vcode)).count() > 0:
# UserVcode.delete().where((UserVcode.mobile == mobile) & (UserVcode.vcode == vcode)).execute()
user.save()
user.updatesignin()
self.session['user'] = user
if 'oauth' in self.session:
oauth = self.session['oauth']
o = Oauth()
o.uid = user.id
o.openid = oauth['id']
o.src = oauth['src']
o.save()
del self.session['oauth']
self.session.save()
User.update(credit = User.credit + 1).where(User.mobile == mobile).execute()
#if sharer != None
User.update(credit = User.credit + 1).where(User.mobile == sharer).execute()
self.flash("注册成功,请先登录。", "ok")
url="/signup?sharer="+user.mobile
self.redirect(url,permanent=True)
return
#else:
# self.flash("请输入正确的验证码")
else:
self.flash("请输入密码和确认密码")
except Exception, ex:
self.flash(str(ex))
示例2: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import update [as 别名]
def post(self):
if self.get_current_user():
self.redirect("/")
return
mobile = self.get_argument("mobile", None)
password = self.get_argument("password", None)
apassword = self.get_argument("apassword", None)
vcode = self.get_argument("vcode", None)
sharer = self.get_argument("sharer", None)
openid = self.get_argument("openid", None)
user = User()
user.mobile = mobile
user.openid = openid
print openid
user.password = User.create_password(password)
try:
user.validate()
if password and apassword:
if len(password) < 6:
self.flash("请确认输入6位以上新密码")
elif password != apassword:
self.flash("请确认新密码和重复密码一致")
else:
if UserVcode.select().where((UserVcode.mobile == mobile) & (UserVcode.vcode == vcode)).count() > 0:
UserVcode.delete().where((UserVcode.mobile == mobile) & (UserVcode.vcode == vcode)).execute()
user.save()
if 'oauth' in self.session:
oauth = self.session['oauth']
o = Oauth()
o.uid = user.id
o.openid = oauth['id']
o.src = oauth['src']
o.save()
del self.session['oauth']
self.session.save()
print sharer
User.update(credit = User.credit + 1).where(User.mobile == mobile).execute()
#if sharer != None
User.update(credit = User.credit + 1).where(User.mobile == sharer).execute()
self.flash("注册成功,请先登录。", "ok")
self.redirect("/signin")
return
else:
self.flash("请输入正确的验证码")
else:
self.flash("请输入密码和确认密码")
except Exception, ex:
self.flash(str(ex))
示例3: __init__
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import update [as 别名]
class Single:
def __init__(self, client):
self.model = User(client, bcrypt)
def on_get(self, req, resp, user_id):
if authorize_as(req.auth, 'developer'):
resource = self.model.find(user_id)
if resource != None:
resp.body = dumps(resource)
else:
resp.status = HTTP_404
else:
raise HTTPUnauthorized('unautharized', 'unautharized')
def on_put(self, req, resp, user_id):
try:
if(authorize_as(req.auth, 'developer')):
is_dev = True
except:
is_player = authorize_as(req.auth, 'player')
is_dev = False
if not is_player:
raise HTTPUnauthorized('unautharized', 'unautharized')
body = loads(req.stream.read().decode('utf-8'))
resource = self.model.update(body, user_id, is_dev)
if resource.modified_count == 1:
resp.status = HTTP_204
else:
raise HTTPBadRequest('failed to update resource',
'a resource with id: ' + user_id + ' was not found')
示例4: test_update
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import update [as 别名]
def test_update(loop):
user = User(id = '111',name = 'fff')
yield from create_pool(loop,**kw)
yield from user.update()
print('update')