I am having trouble with the getting the correct response for a Python Query on Google App Engine.
Here is the LOG from GAE, it successfully prints out the object that matches the query parameters, but now I am trying to send that objects data as JSON back. I am creating a rudimentary user auth system that queries for a USER object using email and password, and if it exists than it returns all the data back.
How can I break down this query to return the data that was found?
E 00:21:06.352 Encountered unexpected error from ProtoRPC method implementation: AttributeError ('list' object has no attribute 'email')
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0/protorpc/wsgi/service.py", line 181, in protorpc_service_app
response = method(instance, request)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/endpoints-1.0/endpoints/api_config.py", line 1332, in invoke_remote
return remote_method(service_instance, request)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/protorpc-1.0/protorpc/remote.py", line 412, in invoke_remote_method
response = method(service_instance, request)
File "/base/data/home/apps/s~caramel-theory-800/1.381271940209425490/photoswap_api.py", line 34, in user_auth
return UserCreateResponseMessage(email=query.email, password=query.password, username=query.username,
AttributeError: 'list' object has no attribute 'email'
E 00:21:06.360 [User(key=Key('User', 5086441721823232), email=u'pop', password=u'top', username=u'yop')]
Here is the ENDPOINT API
I believe the issue is within the last line of code where it trys to return the results of the query (UserAuthResponseMessage)..
@endpoints.method(UserAuthRequestMessage, UserAuthResponseMessage,
path='user', http_method='GET',
name='user.auth')
def user_auth(self, request):
# create some type of query to check for email address, and than check to see if passwords match
query = User.query(User.email == request.email, User.password == request.password).fetch()
print query
# return the info from the server
return UserCreateResponseMessage(email=query[0].email, password=query[0].password, username=query[0].username,
id=query[0].key.id())
APPLICATION = endpoints.api_server([PhotoswapAPI], restricted=False)