def get_by_username(username): row = hsdb.get('users', ('username', 'id', 'password', 'ready_photos'), username, index_name='users_by_username') if row: return User(row['id'], row['username'], row['password'], row['ready_photos']) else: raise User.DoesNotExist()
def get(id): row = hsdb.get('users', ('id', 'username', 'password', 'ready_photos'), id) if row: return User(row['id'], row['username'], row['password'], row['ready_photos']) else: raise User.DoesNotExist()
def create(username, password): password = hash_password(password) try: hsdb.insert('users', ('id', 'username', 'password', 'ready_photos', 'all_photos'), ('', username, password, 0, 0)) except hsdb.OperationalError: raise IntegrityError() else: row = hsdb.get('users', ('username', 'id'), username, index_name='users_by_username') return User(row['id'], username, password, 0)
def create(username, password): password = hash_password(password) try: hsdb.insert( 'users', ('id', 'username', 'password', 'ready_photos', 'all_photos'), ('', username, password, 0, 0)) except hsdb.OperationalError: raise IntegrityError() else: row = hsdb.get('users', ('username', 'id'), username, index_name='users_by_username') return User(row['id'], username, password, 0)