def has_account(self, username): return _.first(samples.users, lambda u: u.username == username) is not None
def find_user_by_id(user_id): return _.first(samples.users, lambda u: u.id == user_id)
def authenticate(self, username): u = _.first(samples.users, lambda u: u.username == username) if not u: return None return attrdict(id=u.id, password=u.password)