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


Python User.register方法代码示例

本文整理汇总了Python中models.user.User.register方法的典型用法代码示例。如果您正苦于以下问题:Python User.register方法的具体用法?Python User.register怎么用?Python User.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.user.User的用法示例。


在下文中一共展示了User.register方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import register [as 别名]
def register_user():
	email = request.form['email']
	password = request.form['password']

	User.register(email, password)

	return render_template('profile.html', email=session['email'])
开发者ID:asimonia,项目名称:web-blog,代码行数:9,代码来源:app.py

示例2: done

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import register [as 别名]
 def done(self):
     u = User.by_name(self.username)
     if u:
         msg = " The user already exists"
         self.render('signup_page.html', error1=msg)
     else:
         u = User.register(self.username, self.password, self.email)
         u.put()
         self.login(u)
         self.redirect('/welcome')
开发者ID:pribala,项目名称:udacity_projects,代码行数:12,代码来源:main.py

示例3: user_register

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import register [as 别名]
def user_register():
    u"""用户注册"""
    if request.method == "POST":
        data = request.form
        email = data.get("email")
        username = data.get("username")
        password = set_password_salt(data.get("password"))

        if User.register(g.db, email,password, Config.pic,username):
            if user_email_check(email):
                flash(u"发送了验证邮件,请注意查收,点击确认之后就可以登陆了")
                return redirect("/login")
    return render_template("register.html")
开发者ID:wangyu190810,项目名称:nedujob,代码行数:15,代码来源:user.py

示例4: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import register [as 别名]
 def post(self, *args, **kwargs):
     """"""
     username = self.get_argument('username', None)
     password = self.get_argument('password', None)
     if username is None or password is None:
         raise TError(code=2001, msg='username or password not valid')
     uid = User.login(username, password)
     if uid is None:
         if not User.username_exists(username):
             uid = User.register(username, password)
     if uid is None:  #
         self.redirect('/dyw/login')
         return
     self.session.set_session(dict(uid=uid))
     self.set_secure_cookie('sid', self.session.sid, domain=self.settings['cookie_domain'])
     self.redirect('/')
开发者ID:ryanduan,项目名称:duanyongwang,代码行数:18,代码来源:auth.py

示例5: get

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import register [as 别名]
 def get(self):
     session = self.backend.get_session()
     response = Response()
     try:
         username = self.get_argument('username', None, True)
         password = self.get_argument('password', None, True)
         user = User.register({'username': username, 'password': password})
         session.add(user)
         session.commit()
         response.add_data(user.as_dict())
     except IntegrityError:
         response.add_error_message('Username already exists')
     except Exception:
         response.add_error_message('Exception while adding a new user')
     finally:
         session.rollback()
     self.write(response.as_dict())
开发者ID:amitittyerah,项目名称:tornado-boilerplate,代码行数:19,代码来源:user.py

示例6: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import register [as 别名]
    def post(self):
        '''
        creates a new user instance and inserts it into the db.
        logs the user in, then redirects the user to the welcome page.

        if there are any errors, render the signup form again with
        the appropriate saved data and error messages
        '''
        have_error = False

        self.username = self.request.get("username").encode("latin-1")
        self.password = self.request.get("password").encode("latin-1")
        self.verify = self.request.get("verify").encode("latin-1")
        self.email = self.request.get("email").encode("latin-1")

        params = dict(username=self.username,
                      email=self.email)

        # check for any errors
        if not valid_username(self.username):
            params['username_error'] = "That's not a valid username"
            have_error = True
        elif User.by_name(self.username):
                params['username_error'] = 'That user already exists'
                have_error = True

        if not valid_password(self.password):
            params['password_error'] = "That's not a valid password"
            have_error = True
        elif self.password != self.verify:
            params['verify_error'] = "Your passwords don't match"

        if not valid_email(self.email):
            params['email_error'] = "That's not a valid email"
            have_error = True

        # there's some error(s)
        if have_error:
            self.render("users/signup.html", **params)
        # succest!!
        else:
            user = User.register(self.username, self.password, self.email)
            user.put()

            self.login(user)
            self.redirect('/welcome')
开发者ID:tiffanyhan,项目名称:poetry-blog,代码行数:48,代码来源:users.py

示例7: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import register [as 别名]
    def post(self):
        params = {}
        have_error = False
        
        params['username'] = user_username = self.request.get('username')
        user_password = self.request.get('password')
        user_verify   = self.request.get('verify')
        params['email']    = user_email    = self.request.get('email')
                
        valid_user = valid_username(user_username)
        valid_pass = valid_password(user_password)
        valid_mail = valid_email(user_email)
        
        if not valid_user:
            have_error = True
            params['error_username'] = 'That was not a valid username'
        if User.by_name(user_username):
            have_error = True
            params['error_username'] = 'Username already exists'
        if not valid_pass:
            have_error = True
            params['error_password'] = 'Not a valid password'
        if user_password != user_verify:
            have_error = True
            params['error_verify'] = "Your passwords didn't match"
        if not valid_mail:
            have_error = True
            params['error_email'] = 'That was not a valid e-mail'

        if have_error:
            self.render('signup.html', **params)
        else:
            new_user = User.register(user_username, user_password, user_email)
            new_user.put()
            self.user = new_user
            self.login(self.user)
            self.redirect('/welcome')
开发者ID:simzou,项目名称:udacity-google-app-engine,代码行数:39,代码来源:signup.py

示例8: parse_request

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import register [as 别名]
 def parse_request(self, data):
     tokenz = data.split("#")
     code = tokenz[0]
     args = tokenz[1:]
     if not self.loggedin:
         if code == "LGN_REQ":
             x = User.login(args[0], args[1])
             if x == 0:
                 self.client_socket.send("LGN_RES#0\n")
             elif x == 2:
                 self.client_socket.send("LGN_RES#2\n")
             else:
                 self.user = x
                 self.loggedin = True
                 self.client_socket.send("LGN_RES#1\n")
                 
         elif code == "REG_REQ":
             x = User.register(args[0], args[1])
             if x == 0:
                 self.client_socket.send("REG_RES#0\n")
             elif x == 1:
                 self.client_socket.send("REG_RES#1\n")
                 
         elif code == "ACT_REQ":
             x = User.verify(args[0], args[1])
             if x == 0:
                 self.client_socket.send("ACT_RES#0\n")
             else:
                 self.user = x
                 self.loggedin = True
                 self.client_socket.send("ACT_RES#1\n")
     else:
         if code == "MAK_VOT":
             x = self.user.vote(args[0], args[1])
             if x == 0:
                 self.client_socket.send("RES_VOT#0\n")
             elif x == 1:
                 self.client_socket.send("RES_VOT#1\n")
         
         elif code == "POLL_REQ":
             x = Poll.get_by_id(args[0])
             if x == 0:
                 self.client_socket.send("POLL_RES#0\n")
             else:
                 self.client_socket.send("POLL_RES#"+str(x)+"\n")
         elif code == "CHK_VOT":
             x = self.user.check_vote(args[0])
             if x == 0:
                 self.client_socket.send("CHK_RES#0")
             else:
                 self.client_socket.send("CHK_RES#" + x +"\n")
             
         elif code == "LGO_REQ":
             self.user = None
             self.loggedin = False
         elif code == "DCR_POL":
             if self.user.is_admin == 1:
                 poll = Poll.get_by_id(args[0])
                 if poll == 0:
                     self.client_socket.send("RES_VOT#0\n")
                 else:
                     poll.get_result(poll.private_key)
             else:
                 self.client_socket.send("RES_VOT#2\n")
         elif code == "create":
             pass 
开发者ID:mostafazh,项目名称:evote,代码行数:68,代码来源:server.py

示例9: register

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import register [as 别名]
def register():
    form = request.form
    # 用类函数来判断
    u = User.register(form)
    return redirect(url_for('.index'))
开发者ID:ChaoyanJiang,项目名称:hello-world,代码行数:7,代码来源:index.py


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