Пример #1
0
 def __init__(self, handlers):
     XmlRpcServer.__init__(self)
     self.handler = {}
     for hname, h in handlers:
         assert hname not in self.handler
         self.handler[hname] = h
         self._wrap_api(hname)
Пример #2
0
class XMLRpcHandler(webapp.RequestHandler):
    rpcserver = None

    def __init__(self):
        self.rpcserver = XmlRpcServer()
        api = ServerAPI()
        self.rpcserver.register_class('api',api)

    def post(self):
        # validate request
        # extract method name and params
        try:
            request = StringIO(self.request.body)
            request.seek(0)
            params, rpccall = xmlrpclib.loads(request.read())
        except:
            self.response.out.write(
                xmlrpclib.dumps(xmlrpclib.Fault
                                (-32000, 'Could not parse request'),
                                methodresponse = True))
            return

        #logging.info('method: %s  params: %s' % (str(rpccall), str(params)))
        # check if this call is not to login
        if 'login' not in str(rpccall):
            # extract sid from params list
            sid = params[0]
            try:
                global global_session
                global_session = sessions.Session(sid=sid)
            except:
                # invalid session id
                # user not logged in
                self.response.out.write(
                    xmlrpclib.dumps(xmlrpclib.Fault
                        (-32000, 'User not logged in'),
                        methodresponse = True))
                return
            params = params[1:]
            # rebuild the request
            request = StringIO(xmlrpclib.dumps(
                params, rpccall, methodresponse=False))

        request.seek(0)
        response = StringIO()
        try:
            self.rpcserver.execute(request, response, None)
        except Exception, e:
            logging.error('Error executing: ' + str(e))
            for line in traceback.format_exc().split('\n'):
                logging.error(line)
        finally:
Пример #3
0
class XMLRpcHandler(webapp.RequestHandler):
    rpcserver = None

    def __init__(self):
        webapp.RequestHandler.__init__(self)
        self.rpcserver = XmlRpcServer()
        #alice = AliceBot()
        self.rpcserver.register_class('alice', alice)

    def post(self):
        request = StringIO(self.request.body)
        request.seek(0)
        response = StringIO()
        try:
            self.rpcserver.execute(request, response, None)
        except Exception, e:
            logging.error('Error executing: ' + str(e))
            for line in traceback.format_exc().split('\n'):
                logging.error(line)
        finally:
Пример #4
0
class XMLRpcHandler(webapp.RequestHandler):
    rpcserver = None

    def __init__(self):
        webapp.RequestHandler.__init__(self)
        self.rpcserver = XmlRpcServer()
        # alice = AliceBot()
        self.rpcserver.register_class("alice", alice)

    def post(self):
        request = StringIO(self.request.body)
        request.seek(0)
        response = StringIO()
        try:
            self.rpcserver.execute(request, response, None)
        except Exception, e:
            logging.error("Error executing: " + str(e))
            for line in traceback.format_exc().split("\n"):
                logging.error(line)
        finally:
Пример #5
0
 def __init__(self):
     self.rpcserver = XmlRpcServer()
     api = ServerAPI()
     self.rpcserver.register_class('api',api)
Пример #6
0
 def __init__(self):
     webapp.RequestHandler.__init__(self)
     self.rpcserver = XmlRpcServer()
     #alice = AliceBot()
     self.rpcserver.register_class('alice', alice)
Пример #7
0
 def __init__(self):
     webapp.RequestHandler.__init__(self)
     self.rpcserver = XmlRpcServer()
     # alice = AliceBot()
     self.rpcserver.register_class("alice", alice)