Created
October 27, 2015 12:39
-
-
Save justanr/f52662efbf661ba14c9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserNotFound(Exception): | |
@classmethod | |
def by_username(cls, username): | |
return cls("No user found with username: {0}".format(username)) | |
def find_user(username): | |
user = User.query.filter_by(username==username).first() | |
if not user: | |
raise UserNotFound.by_username(username) | |
return user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment