def get_user(name=None, customer=None): """Gets a User instance. Args: name: Name of the user. customer: Customer instance to check user against. Returns: A User instance if found, None otherwise. """ if not name: return None valid_user = None if customer: users = customer.get_users() for user in users: if user.name == name: valid_user = _db.get_user(name) else: valid_user = _db.get_user(name) return valid_user
def get_users(customer=None): """Gets all of the user's belonging to a Customer. Args: customer: Customer instance to check users against. Returns: A list of users. """ if not customer: return None customer_users = customer.get_users() users = [] for user in customer_users: u = _db.get_user(user.name) if u: users.append(u) return users