-1
class RPCHandler(webapp2.RequestHandler):
       def __init__(self):
        webapp2.RequestHandler.__init__(self)
        self.methods = ConceptsRPCMethods()
    def get(self):
        func = None
        action = self.request.get('action')
        if action:
            if action[0] == '_':
                self.error(403) # access denied
                return
            else:
                func = getattr(self.methods, action, None)
        if not func:
            self.error(404) # file not found
            return
    else :
        args = ()
        while True:
            key = 'arg%d' % len(args)
            val = self.request.get(key)
            if val:
                args = (json.loads(val),)
            else:
                break
        result = func(*args)

       self.response.out.write(json.dumps(result))

I will explain my program more. The problem is when the user clicks on a tree structure, this sends an action (using an XMLHTTPRequest object) to my code using callback function on whether to expand the tree one more level or display information on the page.

So, the above code should receive the required action from the callback function which sends 3 pieces of information (Get method, function, async) so that the ConceptRPCMethods() could handle the requested order.

YAHOO.util.Connect.asyncRequest('GET', '/rpc?' + query, callback);

I guess I need to make the python code receive 3 parameters but I don't know where to add it or how???

Thanks a lot

pnv
  • 2,985
  • 5
  • 29
  • 36
Noorhan Abbas
  • 31
  • 1
  • 5

1 Answers1

0
class foo(object):

    def __init__(self, arg1, arg2):
       blah
       blah 

__init__ takes self by default, so make sure you are only passing the other arguments : arg1 and arg2.

Most likely your class constructor does not need any other arguments but you are passing some arguments to the constructor and hence the error message.

Ankur Agarwal
  • 23,692
  • 41
  • 137
  • 208