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


Python User.exist方法代码示例

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


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

示例1: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import exist [as 别名]
 def post(self):
     password1 = self.get_argument('password1', '')
     password2 = self.get_argument('password2', '')
     username = self.current_user().username
     next = self.get_argument("next", "")
     error = False
     if len(password1) < 3 or len(password1) > 18:
         error = True
         self.messages.error('密码长度必须大于3小于18!')
     if len(password2) < 3 or len(password2) > 18:
         error = True
         self.messages.error('密码长度必须大于3小于18!')
     if password1 != password2:
         error = True
         self.messages.error('您输入的密码不一致!')
     if not User.exist(username):
         error = True
         self.messages.error('用户不存在!')
     if not error:
         User.update_pass(username, password1)
         self.messages.success('账户密码修改成功!')
         if next:
             return self.redirect(next)
         self.redirect('/')
     else:
         if next:
             return self.redirect(next)
         self.redirect('/')
开发者ID:jtwmyddsgx,项目名称:1024,代码行数:30,代码来源:user.py

示例2: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import exist [as 别名]
    def post(self):
        username = self.get_argument("username")
        password = self.get_argument("password")
        password_again = self.get_argument("password_again")
        next = self.get_argument('next', None)

        error = False
        if not (3 <= len(username) <= 15):
            error = True
            self.messages.error("用户名长度必须在 3-15 之间")
        if len(password) < 3:
            error = True
            self.messages.error("密码长度必须大于等于3")
        if User.exist(username):
            error = True
            self.messages.error("用户已存在!")
        if password != password_again:
            error = True
            self.messages.error("两次输入的密码不一致!")

        if not error:
            u = User.new(username, password)
            self.messages.success("账户创建成功!")
            self.redirect(url_for('signin') + (('?next=%s' % next) if next else ''))
            return

        self.render('user/signup.html')
开发者ID:FashtimeDotCom,项目名称:fpage,代码行数:29,代码来源:user.py

示例3: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import exist [as 别名]
 def post(self, *args, **kwargs):
     comment = self.get_argument("comment", "")
     user_re = re.compile(r"@(\S{3,19}) (.*)")
     try:
         foruser = user_re.search(comment).group(1)
         if not User.exist(foruser):
             foruser = ""
         else:
             comment = user_re.search(comment).group(2)
     except Exception as e:
         foruser = ""
     article_key = self.get_argument("article_key", "")
     user = self.current_user()
     if user is not None:
         username = user.username
     else:
         username = "游客"
     if user is not None and user.level == 0:
         self.messages.error("您暂时无法评论!")
     elif Comment.num_lim(username):
         self.messages.error("评论过多,暂时无法评论,请联系管理员!")
     elif comment != "":
         Comment.new(username, foruser, comment, article_key)
         self.messages.success("评论成功!")
     self.redirect("/spider/" + article_key)
开发者ID:jtwmyddsgx,项目名称:1024,代码行数:27,代码来源:article.py

示例4: sign_up

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import exist [as 别名]
def sign_up():
    error = None
    if request.method == 'POST':
        if User.exist(request.form['username']):
            error = "username exist"
            return render_template('sign_up.html', error=error)
        else:
            result = User.add(request.form['username'], request.form['password'])
            flash('sign up success')
            return redirect(url_for('index'))
    else:
        return render_template('sign_up.html', error=error)
开发者ID:dqw,项目名称:flask_blog,代码行数:14,代码来源:blog.py

示例5: get

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import exist [as 别名]
 def get(self, *args, **kwargs):
     username = self.get_argument("username", "")
     if len(username) < 3:
         return self.write("用户名长度必须大于2!")
     elif len(username) > 18:
         return self.write("用户名长度必须小于18")
     if username != "":
         existed = User.exist(username)
         if existed:
             self.write("该用户已存在..")
         else:
             self.write("该用户可用.")
     else:
         self.send_error(status_code=404)
开发者ID:jtwmyddsgx,项目名称:1024,代码行数:16,代码来源:user.py

示例6: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import exist [as 别名]
    def post(self):
        words = self.get_argument('words', '')  # 用户的留言
        dele_by_key = self.get_argument('theKey', '')
        IP = self.request.headers["X-Forwarded-For"]
        user = self.current_user()
        username = None
        word_user = None
        word_username = None
        if user is None:
            user = JsDict()
            user.username = "游客"

        if dele_by_key != "":
            word_user = Board.get_one(Board.key == dele_by_key)
        if word_user is not None:
            word_username = word_user.username
        if user is not None:
            username = user.username
        if dele_by_key:
            if user.is_admin() or username == word_username:  # 如果不是admin用户将无法删除
                Board.dele_by_key(dele_by_key)
                self.write("删除成功!")
            else:
                self.write("您没有删除权限!")
        elif words:
            username = user.username
            user_re = re.compile(r"@(\S{3,19}) (.*)")
            try:
                foruser = user_re.search(words).group(1)
                if not User.exist(foruser):
                    foruser = ""
                else:
                    words = user_re.search(words).group(2)
            except Exception as e:
                foruser = ""
            if Board.num_lim(username):
                self.messages.error("留言过多,请联系管理员!")
                self.redirect("/board")
            elif user.username != "游客" and user.level == 0:
                self.messages.error("您暂时无法留言!")
                self.redirect(url_for("board"))
            else:
                Board.new(username, foruser, words, IP)
                self.messages.success("留言成功!")
                self.redirect(url_for("board"))
        else:
            self.redirect(url_for("board"))

        '''
开发者ID:jtwmyddsgx,项目名称:1024,代码行数:51,代码来源:board.py

示例7: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import exist [as 别名]
 def post(self):
     username = self.get_argument('username', '')
     password = self.get_argument('pwd1', '')
     error = False
     if len(username) < 3:
         error = True
         self.messages.error('用户长度必须大于等于3!')
     if len(password) < 3:
         error = True
         self.messages.error('密码长度必须大于等于3!')
     if User.exist(username):
         error = True
         self.messages.error('用户已存在!')
     if not error:
         User.new(username, password)
         self.messages.success('账户创建成功!')
         self.redirect('/signin')
         return
     self.render('user/signup.html')
开发者ID:sbkkt,项目名称:words,代码行数:21,代码来源:user.py

示例8: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import exist [as 别名]
    def post(self):
        username = self.get_argument("username")
        password = self.get_argument("password")

        error = False
        if len(username) < 3:
            error = True
            self.messages.error("用户名长度必须大于等于3")
        if len(password) < 3:
            error = True
            self.messages.error("密码长度必须大于等于3")
        if User.exist(username):
            error = True
            self.messages.error("用户已存在!")

        if not error:
            u = User.new(username, password)
            self.messages.success("账户创建成功!")
            return self.redirect(url_for('signin'))

        self.render('user/signup.html')
开发者ID:Geoion,项目名称:fpage,代码行数:23,代码来源:user.py

示例9: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import exist [as 别名]
    def post(self):
        username = self.get_argument("username")
        password = self.get_argument("pwd1")

        # 相比之前,目前这种方法更加实用
        error = False
        if len(username) < 3:
            error = True
            self.messages.error("用户长度必须大于等于3!")
        if len(password) < 3:
            error = True
            self.messages.error("密码长度必须大于等于3!")
        if User.exist(username):
            error = True
            self.messages.error("用户已存在!")

        if not error:
            User.new(username, password)
            self.messages.success("账户创建成功!")
            self.redirect("/login")
            return

        self.render("register.html")
开发者ID:sbkkt,项目名称:words,代码行数:25,代码来源:board.py

示例10: username

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import exist [as 别名]
def username(username):
    if User.exist(username):
        return 'true'
    else:
        return 'false'
开发者ID:dqw,项目名称:flask_blog,代码行数:7,代码来源:blog.py


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