commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/common/src/commdrivers/xmlrpc DebugSocketS...


From: Jason Cater
Subject: gnue/common/src/commdrivers/xmlrpc DebugSocketS...
Date: Thu, 20 Dec 2001 00:14:54 -0500

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    01/12/20 00:14:53

Modified files:
        common/src/commdrivers/xmlrpc: DebugSocketServer.py 
                                       ServerAdapter.py 

Log message:
        started on the HTTP transport for XML-RPC driver

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/xmlrpc/DebugSocketServer.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: gnue/common/src/commdrivers/xmlrpc/DebugSocketServer.py
diff -c gnue/common/src/commdrivers/xmlrpc/DebugSocketServer.py:1.2 
gnue/common/src/commdrivers/xmlrpc/DebugSocketServer.py:1.3
*** gnue/common/src/commdrivers/xmlrpc/DebugSocketServer.py:1.2 Tue Dec 18 
23:05:45 2001
--- gnue/common/src/commdrivers/xmlrpc/DebugSocketServer.py     Thu Dec 20 
00:14:53 2001
***************
*** 34,40 ****
  
  
  import SocketServer
- import xmlrpcserver
  import xmlrpclib
  
  from gnue.common.commdrivers import GCommBase
--- 34,39 ----
***************
*** 54,60 ****
  
  
    def serve(self):
- #    self.
      pass
  
  
--- 53,58 ----
***************
*** 64,73 ****
    def __init__(self, params):
      DebugSocketServer.__init__(self, params)
  
- 
- 
- class DebugRequestHandler(xmlrpcserver.RequestHandler):
-   pass
  
  
  
--- 62,67 ----
Index: gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py
diff -c gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.4 
gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.5
*** gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.4     Wed Dec 19 
02:50:27 2001
--- gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py Thu Dec 20 00:14:53 2001
***************
*** 35,40 ****
--- 35,41 ----
  
  
  
+ ##############################################################################
  #
  # We provide a server driver...
  #
***************
*** 42,52 ****
  
  
  #from gnue.common.commdrivers._helpers.AsyncSocketServer import 
AsyncHTTPServer
  from DebugSocketServer import HTTPServer
! from gnue.common.commdrivers._helpers import ObjectLibrarian
  
- from gnue.common.commdrivers import GCommBase
  from gnue.common import GComm, GDebug
  
  import string, sys
  
--- 43,55 ----
  
  
  #from gnue.common.commdrivers._helpers.AsyncSocketServer import 
AsyncHTTPServer
+ 
  from DebugSocketServer import HTTPServer
! import BaseHTTPServer
  
  from gnue.common import GComm, GDebug
+ from gnue.common.commdrivers._helpers import ObjectLibrarian
+ from gnue.common.commdrivers import GCommBase
  
  import string, sys
  
***************
*** 206,214 ****
  
  
  
!   ############################################################################
!   #                                                                          #
!   # XML-RPC introspection support                                            #
    # (not part of the "standard",
    # but widely used and expected)
    #
--- 209,217 ----
  
  
  
!   ##########################################################################
!   #                                                                        #
!   # XML-RPC introspection support                                          #
    # (not part of the "standard",
    # but widely used and expected)
    #
***************
*** 240,250 ****
        self.raiseException('InvalidMethodName',
                            'Requested method does not exist')
    #
!   #                                                                          #
!   #                                                                          #
!   ############################################################################
  
  
  #
  # Used internally be the XML-RPC server to proxy
  # between Object-by-Ref and actual objects.
--- 243,324 ----
        self.raiseException('InvalidMethodName',
                            'Requested method does not exist')
    #
!   #                                                                        #
!   #                                                                        #
!   ##########################################################################
! 
! 
! ##############################################################################
! ##############################################################################
! ##############################################################################
! ##############################################################################
  
  
+ ##############################################################################
+ #
+ # Class to Handle the HTTP Post Request
+ #
+ 
+ class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+ 
+   #
+   # Handle the HTTP POST command
+   #
+   # This method based largely on the
+   # sample code in xmlrpcserver.
+   #
+   def do_POST(self):
+     try:
+       # get arguments
+       data = self.rfile.read(int(self.headers["content-length"]))
+       params, method = xmlrpclib.loads(data)
+ 
+       # generate response
+       try:
+         response = self.call(method, params)
+         if type(response) != type(()):
+           response = (response,)
+       except:
+         # report exception back to server
+         GDebug.printMesg(1,
+             'Unexpected Exception in XML-RPC code: %s:%s' % \
+                       (sys.exc_type, sys.exc_value)
+         response = xmlrpclib.dumps(
+            xmlrpclib.Fault(1, "%s:%s" % (sys.exc_type, sys.exc_value)))
+       else:
+         response = xmlrpclib.dumps(response,methodresponse=1)
+     except:
+       # internal error, report as HTTP server error
+       self.send_response(500)
+       self.end_headers()
+     else:
+       # got a valid XML RPC response
+       self.send_response(200)
+       self.send_header("Content-type", "text/xml")
+       self.send_header("Content-length", str(len(response)))
+       self.end_headers()
+       self.wfile.write(response)
+ 
+       # shut down the connection
+       self.wfile.flush()
+       self.connection.shutdown(1)
+ 
+ 
+   #
+   # Call the requested method
+   #
+   def call(self, method, params):
+     print "Dispatching: ", method, params
+     try:
+       server_method = getattr(self, method)
+     except:
+       raise AttributeError, \
+              "Server does not have XML-RPC " \
+              "procedure %s" % method
+     return server_method(method, params)
+ 
+ 
+ ##############################################################################
  #
  # Used internally be the XML-RPC server to proxy
  # between Object-by-Ref and actual objects.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]