[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/common/src/commdrivers _directory/Director...
From: |
Jan Ischebeck |
Subject: |
gnue/common/src/commdrivers _directory/Director... |
Date: |
Thu, 06 Jun 2002 19:56:23 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jan Ischebeck <address@hidden> 02/06/06 19:56:23
Modified files:
common/src/commdrivers/_directory: DirectoryServer.py
common/src/commdrivers/pw_xmlrpc: ClientAdapter.py
ServerAdapter.py
common/src/commdrivers/xmlrpc: ClientAdapter.py
common/src/commdrivers: GCommBase.py
Log message:
pw_xmlrpc uses directoryserver now
support for deleting of dynamic objects
many smaller patches
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/commdrivers/_directory/DirectoryServer.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/commdrivers/pw_xmlrpc/ClientAdapter.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/commdrivers/pw_xmlrpc/ServerAdapter.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/commdrivers/GCommBase.py.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
Patches:
Index: gnue/common/src/commdrivers/GCommBase.py
diff -c gnue/common/src/commdrivers/GCommBase.py:1.17
gnue/common/src/commdrivers/GCommBase.py:1.18
*** gnue/common/src/commdrivers/GCommBase.py:1.17 Sun May 26 15:57:33 2002
--- gnue/common/src/commdrivers/GCommBase.py Thu Jun 6 19:56:23 2002
***************
*** 69,76 ****
self._bindings = bindings
self._rpcdef = rpcdef
- parseParameter(self, params)
-
def allowObjectIntrospection(self,allow):
# allow the remote client to get the type of an object by its handle
# an to get other introspection details by that
--- 69,74 ----
***************
*** 92,105 ****
def runService(self, method, data):
pass
- def parseParameter(self, params):
- server.__init__(self)
- try:
- self._port = params['port']
- except KeyError:
- raise GComm.AdapterConfigurationError,\
- _('Required parameter "port" not supplied')
-
#
# Return an exception
--- 90,95 ----
Index: gnue/common/src/commdrivers/_directory/DirectoryServer.py
diff -c gnue/common/src/commdrivers/_directory/DirectoryServer.py:1.3
gnue/common/src/commdrivers/_directory/DirectoryServer.py:1.4
*** gnue/common/src/commdrivers/_directory/DirectoryServer.py:1.3 Mon May
6 18:56:04 2002
--- gnue/common/src/commdrivers/_directory/DirectoryServer.py Thu Jun 6
19:56:23 2002
***************
*** 51,57 ****
self.addStandardMethods()
# Add all the grpc defined methods
# to our internal "service directory"
! self._xmlrpc_mapObjects(rpcdef,bindings)
GDebug.printMesg(3,'XML-RPC Service Directory:\n * %s' % \
string.join(self.directory.keys(),'\n * '))
--- 51,57 ----
self.addStandardMethods()
# Add all the grpc defined methods
# to our internal "service directory"
! self.mapObjects(rpcdef,bindings)
GDebug.printMesg(3,'XML-RPC Service Directory:\n * %s' % \
string.join(self.directory.keys(),'\n * '))
***************
*** 73,85 ****
'binding': self.system__methodHelp,
'help': 'Returns an string with documentation for ' \
+ 'the specified function' }
!
!
#
# Create an internal "service directory"
#
! def _xmlrpc_mapObjects(self, object, bindings, parent=None):
# For servicable objects, maintain a complete "path" for reference
if object._type in ('RpService','RpMethod','RpObject'):
--- 73,88 ----
'binding': self.system__methodHelp,
'help': 'Returns an string with documentation for ' \
+ 'the specified function' }
! self.directory['system.methodSignature'] = \
! { 'signature': ('string',),
! 'binding': self.system__methodSignature,
! 'help': 'Returns an array containing the method signature'}
!
#
# Create an internal "service directory"
#
! def mapObjects(self, object, bindings, parent=None):
# For servicable objects, maintain a complete "path" for reference
if object._type in ('RpService','RpMethod','RpObject'):
***************
*** 187,193 ****
# Now, map our children
for child in object._children:
! self._xmlrpc_mapObjects(child, bindings, object)
## add an method to the directory
--- 190,196 ----
# Now, map our children
for child in object._children:
! self.mapObjects(child, bindings, object)
## add an method to the directory
***************
*** 250,255 ****
--- 253,259 ----
return self.directory[method]
+ ####### Introspection support
def system__listMethods(self):
return self.directory.keys()
***************
*** 267,269 ****
--- 271,284 ----
_('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'))
+
Index: gnue/common/src/commdrivers/pw_xmlrpc/ClientAdapter.py
diff -c gnue/common/src/commdrivers/pw_xmlrpc/ClientAdapter.py:1.4
gnue/common/src/commdrivers/pw_xmlrpc/ClientAdapter.py:1.5
*** gnue/common/src/commdrivers/pw_xmlrpc/ClientAdapter.py:1.4 Sun May 26
15:57:33 2002
--- gnue/common/src/commdrivers/pw_xmlrpc/ClientAdapter.py Thu Jun 6
19:56:23 2002
***************
*** 102,108 ****
url = "%s://%s:%s/" % \
( transport, params['host'], params['port'] )
! self._server = xmlrpclib.Server(url)
except KeyError:
--- 102,113 ----
url = "%s://%s:%s/" % \
( transport, params['host'], params['port'] )
!
!
! # add an list to store references to proxys for dyn. objects
! self._objectProxys=[]
!
! self._server = xmlrpclib.Server(url)
except KeyError:
***************
*** 115,128 ****
def request(self, service, params={}):
! proxy = _ProxyObject(self, service,
servicer=self._server.__getattr__(service))
! return proxy
!
!
! def close(self):
# do a cleanup of the proxy objects and the object stubs
# on the XMLRPC server side
! pass
def runMethod(self, method, *args, **params):
--- 120,152 ----
def request(self, service, params={}):
! self._baseproxy = _ProxyObject(self, service, \
!
servicer=self._server.__getattr__(service))
! return self._baseproxy
!
! def close(self):
# do a cleanup of the proxy objects and the object stubs
# on the XMLRPC server side
!
! # 1. close the proxy objects for services (static, client only)
! self._baseproxy=None
!
! # 2. close the proxy objects for objects (dynamic, client+server)
! for i in self._objectProxys:
! i._close()
! self._objectProxys=[]
!
! # close the client it self
! self._client=None
!
! # just in case the user forgot to delete some objects
! def __del__(self):
! if self._client!=None:
! self.close()
! GCommBase.Client.__del__()
!
! def setTimeout(self,timeout):
! self._timeout=timeout
def runMethod(self, method, *args, **params):
***************
*** 136,143 ****
# check, if an object handle is send
# TODO: make a better check
if type(result)==type("String") and len(result)==40 :
! # create an proxy for this handle
result = _ProxyObject(self, "[%s]" % result)
return result
--- 160,170 ----
# check, if an object handle is send
# TODO: make a better check
if type(result)==type("String") and len(result)==40 :
! # create an proxy for this handle
result = _ProxyObject(self, "[%s]" % result)
+
+ # store proxy in list
+ self._objectProxys.append(result)
return result
***************
*** 165,168 ****
--- 192,199 ----
raise StandardError, data.message
+ def _close(self):
+ # if it is a dynamic object then close it
+ if self._attrPath==[self._attr]:
+ self._adapter.runMethod(self._attr+'._close')
Index: gnue/common/src/commdrivers/pw_xmlrpc/ServerAdapter.py
diff -c gnue/common/src/commdrivers/pw_xmlrpc/ServerAdapter.py:1.4
gnue/common/src/commdrivers/pw_xmlrpc/ServerAdapter.py:1.5
*** gnue/common/src/commdrivers/pw_xmlrpc/ServerAdapter.py:1.4 Mon Jun 3
08:44:09 2002
--- gnue/common/src/commdrivers/pw_xmlrpc/ServerAdapter.py Thu Jun 6
19:56:23 2002
***************
*** 44,54 ****
#from gnue.common.commdrivers._helpers.AsyncSocketServer import
AsyncHTTPServer
! from DebugSocketServer import HTTPServer,MyHTTPServer
import BaseHTTPServer
import SocketServer
from gnue.common import GComm, GDebug
from gnue.common.commdrivers._helpers import ObjectLibrarian
from gnue.common.commdrivers import GCommBase
import string, sys
--- 44,56 ----
#from gnue.common.commdrivers._helpers.AsyncSocketServer import
AsyncHTTPServer
! #from DebugSocketServer import HTTPServer,MyHTTPServer
import BaseHTTPServer
import SocketServer
+ import socket
from gnue.common import GComm, GDebug
from gnue.common.commdrivers._helpers import ObjectLibrarian
+ from gnue.common.commdrivers._directory import DirectoryServer
from gnue.common.commdrivers import GCommBase
import string, sys
***************
*** 80,344 ****
'binary': 'base64'
}
##############################################################################
#
# ServerAdapter
#
! class ServerAdapter(HTTPServer):
def __init__(self, rpcdef, bindings, params):
! HTTPServer.__init__(self, params)
!
! # Keep a directory of all methods we expose and
! # various attributes of those methods (such as
! # "signatures" [as defined by the XML-RPC docs]
! # and help/description information.
! 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' }
! }
!
! # Add all the grpc defined methods
! # to our internal "service directory"
! self._xmlrpc_mapObjects(rpcdef,bindings)
!
! GDebug.printMesg(3,'XML-RPC Service Directory:\n * %s' % \
! string.join(self.directory.keys(),'\n * '))
! GDebug.printMesg(5,'XML-RPC Service Directory:\n%s' % \
! self.directory.keys())
#
! # Create an internal "service directory"
#
! def _xmlrpc_mapObjects(self, object, bindings, parent=None):
- # For servicable objects, maintain a complete "path" for reference
- if object._type in ('RpService','RpMethod','RpObject'):
- if parent and hasattr(parent,'_xmlrpc__path'):
- object._xmlrpc__path = "%s.%s" % (parent._xmlrpc__path, object.name)
- else:
- object._xmlrpc__path = object.name
! ##
! ## Add binding informations to the objects
! ##
! ## services are static objects and
! ## objects are dynamic ones
! ##
! if hasattr(object,'binding'):
! # the direct mapping
! if bindings.has_key(object.binding):
! GDebug.printMesg(3,'XML-RPC Binding Information:');
! GDebug.printMesg(3,' * %s is bound to \n * %s' % \
! (object.binding,bindings[object.binding]))
!
! # for services create an "static" object
! if object._type == 'RpService':
! object._realbinding=bindings[object.binding]()
! else:
! # in all other cases just save the binding information
! object._realbinding=bindings[object.binding]
!
!
! else:
! print _("Missing Binding information. Please add binding "),\
! _("information for "), \
! object.binding
! # care for bindings in all Services
! if object._type == 'RpService':
! if hasattr(object,'_realbinding'):
! pass # nothing to do
else:
! if parent._type == 'RpService':
! try:
! object._realbinding=getattr(parent._realbinding,\
! object.name)
! except:
! raise AttributeError, \
! _("XML-RPC can't bind service '%s' to service '%s'") %\
! (object.name,parent.name)
! elif parent._type == 'RpGnuRpc':
! pass
! else:
! raise AttributeError, \
! _("XML-RPC: cannot bind service '%s' to %s") %\
! (object.name,parent._type)
!
! # Add all methods to our directory
! if object._type == 'RpMethod':
! # Build the signature list...
! signature = []
! # The first element is the return type (can be None)
! if hasattr(object,'type') and len(object.type):
! signature.append(_datatypeMap[object.type])
! else:
! signature.append(None)
! # To make "Object" definitions with w/non-object RPC,
! # the first parameters to any "Object" methods are
! # a "passed reference"
! if parent._type == 'RpObject':
! signature.append(_datatypeMap['string'])
!
! # Then add the argument datatypes...
! for arg in object._arguments:
! signature.append(_datatypeMap[arg.type])
!
!
! # check for the binding
! if hasattr(object,'_realbinding'):
! bindto=object._realbinding
! else:
! if parent._type == 'RpService':
try:
! bindto=getattr(parent._realbinding,object.name)
except:
- raise AttributeError, \
- _("XML-RPC can't bind method '%s' to service '%s'") %\
- (object.name,parent.name)
pass
! else:
! bindto=None
!
! # Add the directory entry
! self.directory[object._xmlrpc__path] = \
! { 'signature': tuple(signature),
! 'help': '', # TODO
! 'binding': bindto }
! #
! # Add all attribute methods to our directory..
! # XML-RPC doesn't support "Attributes", so an
! # attribute is exposed as a pair of get_<name>
! # and set_<name> methods.
! #
! if object._type == 'RpAttribute':
! # To simulate "Object" definitions with w/this
! # non-object RPC, the first parameters to any
! # "Object" methods are a "passed reference"
! if parent._type == 'RpObject':
! getsig = (_datatypeMap[object.type], _datatypeMap['string'])
! setsig = (None, _datatypeMap['string'], _datatypeMap[object.type])
else:
! getsig = (_datatypeMap[object.type],)
! setsig = (None, _datatypeMap[object.type])
!
! if not object.readonly:
! # Add the get_* directory entry
! self.directory['%s.get_%s' % (parent._xmlrpc__path, object.name)] = \
! { 'signature': getsig,
! 'help': '', # TODO
! 'binding': None } # TODO
!
! if not object.writeonly:
! # Add the set_* directory entry
! self.directory['%s.set_%s' % (parent._xmlrpc__path, object.name)] = \
! { 'signature': setsig,
! 'help': '', # TODO
! 'binding': None } # TODO
!
!
! # Now, map our children
! for child in object._children:
! self._xmlrpc_mapObjects(child, bindings, object)
!
! # Sigh... what kind of drugs was I on to volunteer for RPC abstraction?
! def getObject(self,name):
! return obj
!
! def getMethodDirEntry(self,method):
! GDebug.printMesg(6,'XML-RPC Directory entry:\n (%s,%s,%s)' % \
! (self.directory[method]['signature'],\
! self.directory[method]['help'],\
! self.directory[method]['binding']))
- return self.directory[method]
-
- #
- # 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.directory.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'))
! #
! # #
! # #
! ##########################################################################
! def serve(self):
! self._requestHandler = RequestHandler
! self._tcpserver = MyHTTPServer(('',self._port),
! self._requestHandler)
! self._tcpserver.setParent(self)
! try:
! self._tcpserver.serve_forever()
! except KeyboardInterrupt:
! pass
!
- ##############################################################################
- ##############################################################################
- ##############################################################################
- ##############################################################################
##############################################################################
--- 82,364 ----
'binary': 'base64'
}
+ class MyHTTPServer(SocketServer.ThreadingTCPServer):
+ def setParent(self,parent):
+ self._parent=parent
+
+ def server_bind(self):
+ self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+ self.socket.bind(self.server_address)
+
+ # TO BE CHECKED:
+ # Python 2.1: SocketServer.ThreadingMixIn
+ #SocketServer.ThreadingMixIn does not work properly
+ #since it tries to close the socket of a request two
+ #times.
+
+ #Workaround for using SocketServer.ThreadingMixIn under
+ #Python 2.1:
+
+ #class MyThreadingHTTPServer(
+ #SocketServer.ThreadingMixIn,
+ #MyHTTPServer
+ #):
+ #def close_request(self, request):
+ #pass
+
+
##############################################################################
#
# ServerAdapter
#
! class ServerAdapter(DirectoryServer.DirectoryServer):
def __init__(self, rpcdef, bindings, params):
! try:
! self._port = params['port']
! except KeyError:
! raise GComm.AdapterConfigurationError, _('Required parameter "port" not
supplied')
! if hasattr(params,'loglevel'):
! self._loglevel = params['loglevel']
! else:
! self._loglevel = 1
+ DirectoryServer.DirectoryServer.__init__(self, rpcdef, bindings, params)
+
+ # To make "Object" definitions with w/non-object RPC,
+ # the first parameters to any "Object" methods are
+ # a "passed reference"
+ # if parent._type == 'RpObject':
+ # signature.append(_datatypeMap['string'])
+
+ # To simulate "Object" definitions with w/this
+ # non-object RPC, the first parameters to any
+ # "Object" methods are a "passed reference"
#
! # Return an exception
#
! def raiseException(self, exception, message, event=None):
! xmlrpclib.dumps(xmlrpclib.Fault(34543, '%s: %s' % (exception, message)))
! # #
! # #
! ##########################################################################
! def serve(self):
! self._requestHandler = RequestHandler
! self._tcpserver = MyHTTPServer(('',self._port),
! self._requestHandler)
! self._tcpserver.setParent(self)
! try:
! self._tcpserver.serve_forever()
! except KeyboardInterrupt:
! pass
!
! #
! # Call the requested method
! #
! def call(self, method, params):
! if self._loglevel>0:
! print _("Dispatching: "), method, params
!
! ## Check if the Method is part of a service or a pointer to a
! ## single object
! ##
! ## Call to an object: method="_Management:235423456_.getAttr"
! ## params=""
! ## Call to an method: (of a service=one object)
! ## method="DonutPlace.Management.Restart"
! if method[0]=='[':
! # call to an object
! # 1. get the object from the objectlibrarian
! # 2. check, if the object is supported by the gfd
! try:
! i=string.index(method,']',1)
! objhandle=method[1:i]
! method=method[i+2:]
! except ValueError:
! raise AttributeError, \
! _("Wrong format of object handle ")+\
! _("in method call %s") % method
! # TODO check in service dir, if obj is supported or not
! o=ObjectLibrarian.retrieveObject(objhandle)
! try:
! server_method=getattr(o,method)
! server_attribute=None
! except AttributeError:
! server_method=None
! try:
! server_attribute=getattr(o,method[4:])
! except AttributeError:
! if method!="_close":
! msg=_("Internal XMLRPC server error: method %s can be ")% \
! method +\
! _("found in the directory (build out of a .grpc file),")+\
! _(" but the object doesn't contain this method/attribut.")+\
! _(" Please check you .grpc file for wrong return types.")
!
! raise AttributeError, msg
! if method!="_close":
! direntry = self.getMethodDirEntry(o._type+"."+method)
! signature=direntry['signature']
else:
! signature= ('string',)
! else:
! # call to a service method or a helper call (get/set) for
! # a service attribut
! try:
! direntry = self.getMethodDirEntry(method)
! server_method = direntry['binding']
! server_attribute = None
!
! # check if it is an real method (binding -> method)
! # or an get/set method for an attribut (binding-> attribut)
! if (type(server_method)!=type(self.call)):
! server_attribute = server_method
! server_method=None
!
! signature=direntry['signature']
! if (server_method==None) and (server_attribute==None):
! raise AttributeError, \
! _("Server XML-RPC method %s is not ")% method +\
! _("bound to real method")
! except KeyError:
! raise AttributeError, \
! _("Server does not have XML-RPC ") +\
! _("procedure %s") % method
! try:
! #
! pass
! # TODO: Compare submitted attributs with signature
! except KeyError:
! raise AttributeError, \
! _("Server XML-RPC ") +\
! _("procedure %s accepts just %s as attributs") % (method,attr)
!
! # replace object handles in param with the real object
! counter=0
! while counter<len(params):
! p=params[counter]
! if type(p)==type(""):
! if (len(p)==42) and (p[0]=="[") and (p[41]=="]"):
try:
! p=p[1:41]
! obj=ObjectLibrarian.retrieveObject(p)
! newp=params[0:counter-1]+(obj,)+params[counter+1:]
! params=newp
except:
pass
! counter=counter+1;
+ # check if it is an real method (binding -> method)
+ # or an get/set method for an attribut (binding-> attribut)
! if (server_method!=None):
!
! # call method with params
! result=server_method(*params)
! # check if it's the close object method
! elif (method=="_close"):
!
! result=self.releaseDynamicObject(o)
!
! else:
!
! ## check wether its the set or the get method for the attribut
! mparts=string.splitfields(method,'.')
! mparts.reverse()
! calltype=mparts[0]
! calltype=calltype[:4]
! GDebug.printMesg(7,'method %s has calling type %s' %\
! (method,calltype))
! if calltype=='set_':
! # setAttribut method
! server_attribute=params[0]
! elif calltype=='get_':
! # getAttribut method
! result=server_attribute
else:
! raise AttributeError, \
! _("Internal Server XML-RPC error: method type") +\
! _("(get/set attribute) couldn't be detected (method %s)") \
! % method
+ # replace real object in param with an object handle
+ if type(result)==type(self): ## both should be instances
+ ObjectLibrarian.archiveObject(result)
+ # get the type of the result
+ rtype=signature[0]
+ # delete the surrounding brackets < >
+ rtype=rtype[1:len(rtype)-1]
+ # store typeinfo in new object
+ result._type=rtype
! result=ObjectLibrarian.getObjectReference(result)
! self.registerDynamicObject(result,rtype)
+ # check for empty results (not allowed for XMLRPC)
+ if result==None:
+ GDebug.printMesg(3,'Transform result None into 1')
+ result=1
! return result
+ def registerDynamicObject(self,objhandle,type):
+ #
+ # add new methods to the xmlrpc server
+ #
+ tl=len(type)
+ for i in self.directory.keys():
+ if i[0:tl]==type:
+ method="["+objhandle+"]"+i[tl:]
+ GDebug.printMesg(1,'Method %s registered to py-xmlrpc ' \
+ % method +\
+ ' internal directory.')
+ # self.server.addMethods({method:None})
+
+ # add a method to close this object
+ # self.server.addMethods({"["+objhandle+"]._close":None})
! def deregisterDynamicObject(self,object):
! #
! # remove the new methods from the xmlrpc server
! #
! objhandle=ObjectLibrarian.getObjectReference(object)
! type=object._type
! tl=len(type)
! for i in self.directory.keys():
! if i[0:tl]==type:
! method="["+objhandle+"]"+i[tl:]
! GDebug.printMesg(1,'Method %s is deleted from py-xmlrpc ' \
! % method +\
! ' internal directory.')
! # self.server.removeMethods({method:None})
!
! # remove the method to close this object
! # self.server.removeMethods({"["+objhandle+"]._close":None})
!
! def releaseDynamicObject(self,object):
! # delete bindings for this object in the xmlrpc method directory
! # self.deregisterDynamicObject(object)
! # release object for Object Librarian
! ObjectLibrarian.deferenceObject(object)
!
##############################################################################
***************
*** 362,370 ****
# generate response
try:
! response = self.call(method, params)
if response==None:
! response=(1,)
elif type(response) != type(()):
response = (response,)
except:
--- 382,391 ----
# generate response
try:
!
! response = self.server._parent.call(method, params)
if response==None:
! response=()
elif type(response) != type(()):
response = (response,)
except:
***************
*** 393,499 ****
self.connection.shutdown(1)
! #
! # Call the requested method
! #
! def call(self, method, params):
! print _("Dispatching: "), method, params
!
! ## Check if the Method is part of a service or a pointer to a
! ## single object
! ##
! ## Call to an object: method="_Management:235423456_.getAttr"
! ## params=""
! ## Call to an method: (of a service=one object)
! ## method="DonutPlace.Management.Restart"
!
! if method[0]=='[':
! # call to an object
! # 1. get the object from the objectlibrarian
! # 2. check, if the object is supported by the gfd
! try:
! i=string.index(method,']',1)
! objhandle=method[1:i]
! method=method[i+2:]
! except ValueError:
! raise AttributeError, \
! _("Wrong format of object handler ") +\
! _("in method call %s") % method
! # TODO check in service dir, if obj is supported or not
! o=ObjectLibrarian.retrieveObject(objhandle)
! server_method=getattr(o,method)
! else:
!
! # call to a service method
! try:
! direntry = self.server._parent.getMethodDirEntry(method)
! server_method = direntry['binding']
!
! if server_method==None:
! raise AttributeError, \
! _("Server XML-RPC method %s has is not ") + \
! _("bound to real method") % method
! except:
! raise AttributeError, \
! _("Server does not have XML-RPC ") +\
! _("procedure %s") % method
! try:
! attr=direntry['signature']
! # TODO: Compare submitted attributs with signature
! except:
! raise AttributeError, \
! _("Server XML-RPC ") +\
! _("procedure %s accepts just %s as attributs") % (method,attr)
!
! # replace object handles in param with the real object
! counter=0
! while counter<len(params):
! p=params[counter]
! if type(p)==type(""):
! if (len(p)==42) and (p[0]=="[") and (p[41]=="]"):
! try:
! p=p[1:41]
! obj=ObjectLibrarian.retrieveObject(p)
! newp=params[0:counter-1]+(obj,)+params[counter+1:]
! params=newp
! except:
! pass
! counter=counter+1;
!
!
! # call method with params
! if len(params)==0:
! result=server_method()
! elif len(params)==1:
! result=server_method(params[0])
! elif len(params)==2:
! result=server_method(params[0],params[1])
! elif len(params)==3:
! result=server_method(params[0],params[1],params[2])
! elif len(params)==4:
! result=server_method(params[0],params[1],params[2],params[3])
! elif len(params)==5:
! result=server_method(params[0],params[1],params[2],params[3],\
! params[4])
! elif len(params)==6:
! result=server_method(params[0],params[1],params[2],params[3],\
! params[4],params[5])
! elif len(params)==7:
! result=server_method(params[0],params[1],params[2],params[3],\
! params[4],params[5],params[6])
! else:
! raise AttributeError,\
! _("Too many param for XML-RPC ") + \
! _("procedure %s") % method
!
! # replace real object in param with an object handle
! if type(result)==type(self): ## both should be instances
! ObjectLibrarian.archiveObject(result)
! result=ObjectLibrarian.getObjectReference(result)
!
! return result
!
!
##############################################################################
#
# Used internally by the XML-RPC server to proxy
--- 414,421 ----
self.connection.shutdown(1)
! ###########################
! # The following part is not used at the moment
##############################################################################
#
# Used internally by the XML-RPC server to proxy
Index: gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py
diff -c gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py:1.9
gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py:1.10
*** gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py:1.9 Mon May 27
14:06:45 2002
--- gnue/common/src/commdrivers/xmlrpc/ClientAdapter.py Thu Jun 6 19:56:23 2002
***************
*** 249,255 ****
_("please check if the server is running")
#raise GComm.CommunicationsError, msg
else:
! msg="Error: %s" % sys.exc_value
print
print "********************************************\n"
--- 249,255 ----
_("please check if the server is running")
#raise GComm.CommunicationsError, msg
else:
! msg="Error: %s" % (sys.exc_value,)
print
print "********************************************\n"
***************
*** 258,266 ****
sys.exit(0)
elif str(sys.exc_type)=="xmlrpc.fault":
! msg =_("Error '%s' occured on server connected"+ \
! " by XMLRPC") % sys.exc_value.faultString
! raise GComm.DistantError,msg,sys.exc_traceback
else:
raise GComm.Error, _("Unknown XMLRPC Error: '%s' of type '%s'") % \
--- 258,286 ----
sys.exit(0)
elif str(sys.exc_type)=="xmlrpc.fault":
! #
! # Distinguish between different kinds of distant RPC errors
! #
!
! # catch unknown service faults created by xmlrpc/ServerAdapter
! if sys.exc_value.faultString[:30]=='xmlrpc.error: unknown command:':
! msg=_("Service/Command %s does not exist on the server")\
! % sys.exc_value.faultString[31:]
! raise GComm.InvalidService,msg,sys.exc_traceback
!
! # catch unknown service faults created by pw_xmlrpc/ServerAdapter
! elif sys.exc_value.faultString[:26]== \
! 'exceptions.AttributeError:':
! msg=_("%s")\
! % sys.exc_value.faultString[26:]
! raise GComm.InvalidService,msg,sys.exc_traceback
!
! # catch every other distant error
! else:
! msg =_("Error '%s' occured on server connected"+ \
! " by XMLRPC") % sys.exc_value.faultString
! raise GComm.DistantError,msg,sys.exc_traceback
!
else:
raise GComm.Error, _("Unknown XMLRPC Error: '%s' of type '%s'") % \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/common/src/commdrivers _directory/Director...,
Jan Ischebeck <=