今天学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()


太坏了。。。