Пример #1
0
 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()
Пример #2
0
 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()
Пример #3
0
 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()
Пример #4
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)
Пример #5
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)
Пример #6
0
 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()