commit-gnue
[Top][All Lists]
Advanced

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

gnue/common/src/commdrivers _parser/Objects.py ...


From: Jason Cater
Subject: gnue/common/src/commdrivers _parser/Objects.py ...
Date: Tue, 18 Dec 2001 01:48:43 -0500

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    01/12/18 01:48:43

Modified files:
        common/src/commdrivers/_parser: Objects.py 
        common/src/commdrivers/xmlrpc: ServerAdapter.py 

Log message:
        added xml-rpc directory/introspection services

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/commdrivers/_parser/Objects.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.1&tr2=1.2&r1=text&r2=text

Patches:
Index: gnue/common/src/commdrivers/_parser/Objects.py
diff -c gnue/common/src/commdrivers/_parser/Objects.py:1.2 
gnue/common/src/commdrivers/_parser/Objects.py:1.3
*** gnue/common/src/commdrivers/_parser/Objects.py:1.2  Thu Dec  6 18:19:42 2001
--- gnue/common/src/commdrivers/_parser/Objects.py      Tue Dec 18 01:48:42 2001
***************
*** 71,77 ****
      GObj.__init__(self, parent, type="RpException")
  
  
! # exception object
  class RpcRaises (GObj):
    def __init__(self, parent=None):
      GObj.__init__(self, parent, type="RpException")
--- 71,77 ----
      GObj.__init__(self, parent, type="RpException")
  
  
! # exception declaration object
  class RpcRaises (GObj):
    def __init__(self, parent=None):
      GObj.__init__(self, parent, type="RpException")
Index: gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py
diff -c gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.1 
gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.2
*** gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.1     Mon Dec 17 
20:10:28 2001
--- gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py Tue Dec 18 01:48:43 2001
***************
*** 69,80 ****
      HTTPServer.__init__(self, rpcdef, bindings, params)
  
  
  
  
    def raiseException(self, exception, message, event=None):
      xmlrpclib.dumps(xmlrpclib.Fault(34543, '%s: %s' % (exception, message)))
  
  
-   def _xmlrpc_mapObject(self,
  
  
--- 69,163 ----
      HTTPServer.__init__(self, rpcdef, bindings, params)
  
  
+     self.directory = {
+        'system.listMethods':
+            { 'signature': ('string',),
+              'binding':   self.system__listMethods,
+              'help':      'Returns an array of all supported methods' },
+        'system.methodSignature':
+            { 'signature': ('string',),
+              'binding':   self.system__methodSignature,
+              'help':      'Returns an array containing the method signature' 
},
+        'system.methodHelp':
+            { 'signature': ('string','string'),
+              'binding':   self.system__methodHelp,
+              'help':      'Returns an string with documentation for ' \
+                         + 'the specified function' }
+        }
  
  
+     # Create our internal "service directory"
+     self._xmlrpc_mapObjects(rpcdef)
+ 
+ 
+   #
+   # Create an internal "service directory"
+   #
+   def _xmlrpc_mapObjects(self, object, parent=None):
+ 
+     # For servicable objects, maintain a complete "path" for reference
+     if object._type in ('RpService','RpMethod','RpObject'):
+       if parent:
+         object._xmlrpc__path = "%s.%s" % (parent._xmlrpc__path, object.name)
+       else:
+         object._xmlrpc__path = object.name
+ 
+     # Add all methods to our directory
+     if object._type == 'RpMethod':
+       self.directory[object._xmlrpc__path] =
+         { 'signature': None,  # TODO
+           'help': '',         # TODO
+           'binding': None   } # TODO
+ 
+     # Now, map our children
+     for child in object._children:
+       self._xmlrpc_mapObjects(child, object)
+ 
+ 
+   #
+   # Return an exception
+   #
    def raiseException(self, exception, message, event=None):
      xmlrpclib.dumps(xmlrpclib.Fault(34543, '%s: %s' % (exception, message)))
  
  
  
+ 
+   ############################################################################
+   #                                                                          #
+   # XML-RPC introspection support                                            #
+   # (not part of the "standard",
+   # but widely used and expected)
+   #
+ 
+   def system__listMethods(self):
+     return self.supportedMethods.keys()
+ 
+ 
+   def system__methodHelp(self, method):
+     if self.directory.has_key(method):
+       try:
+         return self.directory[method]['help']
+       except KeyError:
+         return "No help available for %s" % method
+     else:
+       # TODO: Is this right? If the requested method is not available?
+       self.raiseException('InvalidMethodName',
+                           'Requested method does not exist')
+ 
+ 
+   def system__methodSignature(self, method):
+     if self.directory.has_key(method):
+       try:
+         return (self.directory[method]['signature'],)
+       except KeyError:
+         return None
+     else:
+       # TODO: Is this right? If the requested method is not available?
+       self.raiseException('InvalidMethodName',
+                           'Requested method does not exist')
+   #
+   #                                                                          #
+   #                                                                          #
+   ############################################################################
  



reply via email to

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