首页 > Web开发 > 详细

flask web日常

时间:2015-11-08 14:23:21      阅读:318      评论:0      收藏:0      [点我收藏+]

 今天学flask web开发的时候出了一个bug

column username is not unique

 

上网搜了搜结果发现是作者故意留的一个bug  ....

 

The bug fix

Let‘s fix ournicknameduplication bug.

As discussed earlier, there are two places that are currently not handling duplicates. The first is in theafter_loginhandler for Flask-Login. This is called when a user successfully logs in to the system and we need to create a new User instance. Here is the affected snippet of code, with the fix in it (fileapp/views.py):

if user is None:
        nickname = resp.nickname
        if nickname is None or nickname == "":
            nickname = resp.email.split(‘@‘)[0]
        nickname = User.make_unique_nickname(nickname)
        user = User(nickname = nickname, email = resp.email, role = ROLE_USER)
        db.session.add(user)
        db.session.commit()


太坏了。。。

flask web日常

原文:http://www.cnblogs.com/jjxv/p/4946831.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!