Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Build a Social Network with Flask Broadcasting Stream Views

locked database - Build a Social Network with Flask

It is quite frustrating that you made a teacher's note some time ago regarding the issue of the locked database but you never bothered to fix it in your code in any of the workspaces for the course. So now if I have some troubling issue that I can't seem to track down and wind up restarting my workspace, then I have to go back and fix the damn database issue overtime.

:( Here is the code fix from the teacher's notes on the lesson titled 'Macros'

Note

If you're constantly getting a locked database, change your User.create_user method to the following:

    @classmethod
    def create_user(cls, username, email, password, admin=False):
        try:
            with DATABASE.transaction():
                cls.create(
                    username=username,
                    email=email,
                    password=generate_password_hash(password),
                    is_admin=admin)
        except IntegrityError:
            raise ValueError("User already exists")

[edit: aligned decorator]

Chris Freeman
Chris Freeman
Treehouse Moderator 68,454 Points

Sorry for the trouble. Could please you post your solution, along with the title of the section you were working on. That way others can find your solution in a forum search. Thanks!

Chris Freeman
Chris Freeman
Treehouse Moderator 68,454 Points

Wes, thanks for the update.

Kenneth Love, is Wes' locked database issue still a problem in the workspaces?

1 Answer

Chris,

that's the issue I was frustrated with. There was a teacher's note in one of the lessons of Build a Social Network with Flask regarding a locked database and a code fix to it. However, in none of the following lessons was the associated workspace for that lesson amended with the code fix for the locked database. So every time I loaded a fresh workspace from the lesson I was on, I would have to go back four or five or ten lessons trying to find the code to fix the locked database. I can't remember where it was to be honest and have had to find it too many times already.

Sorry, was just getting very frustrated with that Track that day and especially with Kenneth for never updating all the workspace files with the fixed code.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,454 Points

The OP is the solution. :thumbsup:. Changed this comment to answer. Upvoted. Mark Best Answer.