Google app engine: object does not have ToMessage attribute

I am trying to implement a service that checks if a registered user is in the data store if yes returns True, if it does not return False. Here is the code I'm using:

import endpoints from google.appengine.ext import ndb from protorpc import remote from protorpc import messages from endpoints_proto_datastore.ndb import EndpointsModel from google.appengine.api import users class AuthRes(messages.Message): message = messages.StringField(1) class UserModel(EndpointsModel): user = ndb.UserProperty() @endpoints.api(name='myapi', version='v1', description='My Little API') class MyApi(remote.Service): @UserModel.method(path='myuser', http_method='GET', name='myuser.check') def UserCheck(self, cls): user = users.get_current_user() if user: myuser = cls.query().filter(cls.user.user_id() == user.user_id()).get() if not myuser: return AuthRes(message="False") else: return AuthRes(message="True") else: return AuthRes(message="False") application = endpoints.api_server([MyApi], restricted=False) 

I always get an 'AuthRes' object has no attribute 'ToMessage'

+5
source share
1 answer

Instead, I believe:

 @UserModel.method(path='myuser', http_method='GET', name='myuser.check') 

Do you want to:

 from protorpc import message_types # add at the top @endpoints.method(message_types.VoidMessage, AuthRes, path='myuser', http_method='GET', name='myuser.check') 
0
source

All Articles