I’m creating a webservice for appengine, and I’ve created two functions inside the class WebService.py. And I’m trying to register these functions in a SimpleXMLRPCServer object. But When I pass the function names to the parameters, it says undefined variable.
Here is the code:
import SimpleXMLRPCServer
from google.appengine.ext import webapp
from google.appengine.ext import db
class WebService(webapp.RequestHandler):
def login(self, username, password):
calls = db.GqlQuery("SELECT * from User ORDER BY username DESC LIMIT 10")
for call in calls:
if calls.username == username and calls.password == password:
return True
return False
def register(self, username, password):
db.GqlQuery("INSERT into User (username, password) value(%s, %s)"%(username, password))
return True
server = SimpleXMLRPCServer.SimpleXMLRPCServer(('localhost',8080))
server.register_function(login)
server.register_function(register)
server.serve_forever()
Is this the right way to do it?? If its not, can you please tell me what is wrong in my code??
Thank you!
I just figured it out! I’m still newbie to python, so it is a newbie doubt.
Looks like the problem was with the identation. I needed to put it inside the class identation, so it could find the method.
In fact, it should be like this:
This solved my problem. Thank you for your replies.