def GET(request): """Search for a User using their email address.""" request.check_required_parameters(query={'email': 'string'}) user = User.from_email(request.params_query['email']) user.check_exists() return Response(200, 'Successfully retrieved user.', user.obj)
def GET(request): """Search for a User using their email address.""" # Make sure required parameters are there try: request.check_required_parameters(query={'email': 'string'}) except exceptions.ParameterError as e: return Response(400, e.message) # Instantiate and read a User from the database user = User.from_email(request.params_query['email']) # Make sure this User exists in the database if not user.exists(): return Response(404, '{} not found'.format(user)) # Return this User return Response(200, 'Successfully retrieved {}.'.format(user), user.to_JSON())