def getUsers(self): ''' @see: IUserService.getUsers ''' users = [] for k in range(1, 2): user = User() user.Id = k user.Name = 'User %s' % k users.append(user) return users
def getUsers(self, q=None): ''' @see: IUserService.getUsers ''' users = [] for k in range(1, 10): user = User() user.Id = k user.Name = 'User %s' % k users.append(user) if q: assert isinstance(q, QUser) if QUser.name.like in q: nameRegex = likeAsRegex(q.name.like) users = [user for user in users if nameRegex.match(user.Name)] if QUser.name.ascending in q: users.sort(key=lambda user: user.Name, reverse=not q.name.ascending) return users