码迷,mamicode.com
首页 > Web开发 > 详细

flask web日常

时间:2015-11-08 14:24:09      阅读:182      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!