当前位置: 首页>>代码示例>>Python>>正文


Python User.update方法代码示例

本文整理汇总了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))
开发者ID:yanjinjin,项目名称:dz_csyp,代码行数:61,代码来源:site.py

示例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))
开发者ID:yanjinjin,项目名称:wxshop,代码行数:56,代码来源:site.py

示例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')
开发者ID:monster-club,项目名称:trainer-card,代码行数:33,代码来源:Single.py

示例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')
开发者ID:hcjjy,项目名称:python_webapp,代码行数:7,代码来源:ormTest.py


注:本文中的model.User.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。