Created
March 23, 2015 08:46
-
-
Save 2garryn/379e78d542c3449e18e6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def user_register(session, username, password, email): | |
try: | |
new_user = User(name=username, email=email) | |
session.add(new_user) | |
session.commit() | |
return True, 'ok' | |
except exc.IntegrityError as e: | |
session.rollback() | |
code, msg = e.orig | |
print msg | |
if code == 1062: return False, "User with provided email or username already existed" | |
else: return False, "Internal error" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment