[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/common/src/commdrivers xmlrpc/ServerAdapte...
From: |
Jan Ischebeck |
Subject: |
gnue/common/src/commdrivers xmlrpc/ServerAdapte... |
Date: |
Mon, 06 May 2002 18:56:04 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jan Ischebeck <address@hidden> 02/05/06 18:56:04
Modified files:
common/src/commdrivers/xmlrpc: ServerAdapter.py
common/src/commdrivers/_directory: DirectoryServer.py
Log message:
add support for get/set methods of RpAttributes to the xmlrpc protocoll
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/commdrivers/_directory/DirectoryServer.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: gnue/common/src/commdrivers/_directory/DirectoryServer.py
diff -c gnue/common/src/commdrivers/_directory/DirectoryServer.py:1.2
gnue/common/src/commdrivers/_directory/DirectoryServer.py:1.3
*** gnue/common/src/commdrivers/_directory/DirectoryServer.py:1.2 Fri May
3 13:48:14 2002
--- gnue/common/src/commdrivers/_directory/DirectoryServer.py Mon May 6
18:56:04 2002
***************
*** 147,154 ****
(object.name,parent._type)
! # Add all methods to our directory
! if object._type == 'RpMethod':
# check for the binding
if hasattr(object,'_realbinding'):
--- 147,159 ----
(object.name,parent._type)
! # Compute binding for methods and for attributs
! # both are direct lins to the specific object
! #
! # the dispatcher has to distinguish methods and
! # objects by testing if they are callable
! if (object._type == 'RpMethod') or \
! (object._type == 'RpAttribute'):
# check for the binding
if hasattr(object,'_realbinding'):
***************
*** 161,173 ****
(object._path,bindto))
except:
raise AttributeError, \
! _("GNURPC can't bind method '%s' to service '%s'") %\
(object.name,parent.name)
pass
else:
bindto=None
!
self.addRpMethod(object,parent,bindto)
#
--- 166,178 ----
(object._path,bindto))
except:
raise AttributeError, \
! _("GNURPC can't bind method/attribut '%s' to service
'%s'") %\
(object.name,parent.name)
pass
else:
bindto=None
! if object._type == 'RpMethod':
self.addRpMethod(object,parent,bindto)
#
***************
*** 177,183 ****
# and set_<name> methods.
#
if object._type == 'RpAttribute':
! self.addRpAttribut(object,parent,"")
# Now, map our children
--- 182,188 ----
# and set_<name> methods.
#
if object._type == 'RpAttribute':
! self.addRpAttribut(object,parent,bindto)
# Now, map our children
***************
*** 222,235 ****
if hasattr(object,"helptext"):
helptext=object.helptext
! if not object.readonly:
# Add the get_* directory entry
self.directory['%s.get_%s' % (parent._path, object.name)] = \
{ 'signature': (object.type,),
'help': helptext,
'binding': None } # TODO
! if not object.writeonly:
# Add the set_* directory entry
self.directory['%s.set_%s' % (parent._path, object.name)] = \
{ 'signature': (None, object.type),
--- 227,240 ----
if hasattr(object,"helptext"):
helptext=object.helptext
! if not object.writeonly:
# Add the get_* directory entry
self.directory['%s.get_%s' % (parent._path, object.name)] = \
{ 'signature': (object.type,),
'help': helptext,
'binding': None } # TODO
! if not object.readonly:
# Add the set_* directory entry
self.directory['%s.set_%s' % (parent._path, object.name)] = \
{ 'signature': (None, object.type),
Index: gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py
diff -c gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.13
gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.14
*** gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py:1.13 Sat May 4
12:46:26 2002
--- gnue/common/src/commdrivers/xmlrpc/ServerAdapter.py Mon May 6 18:56:03 2002
***************
*** 130,136 ****
##############################################################################
##############################################################################
! def addRpMethod(self,object,parent,binding):
DirectoryServer.DirectoryServer.addRpMethod(self,object, \
parent,binding)
--- 130,136 ----
##############################################################################
##############################################################################
! def addRpMethod(self,object,parent,binding):
DirectoryServer.DirectoryServer.addRpMethod(self,object, \
parent,binding)
***************
*** 143,156 ****
parent,binding)
if not object.readonly:
! # Add the get_* directory entry
! self.server.addMethods({'%s.get_%s' % \
(parent._path, object.name):\
binding})
if not object.writeonly:
! # Add the set_* directory entry
! self.server.addMethods({'%s.set_%s' % \
(parent._path, object.name):\
binding})
--- 143,156 ----
parent,binding)
if not object.readonly:
! # Add the set_* directory entry
! self.server.addMethods({'%s.set_%s' % \
(parent._path, object.name):\
binding})
if not object.writeonly:
! # Add the get_* directory entry
! self.server.addMethods({'%s.get_%s' % \
(parent._path, object.name):\
binding})
***************
*** 188,212 ****
_("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)
direntry = self.getMethodDirEntry(o._type+"."+method)
signature=direntry['signature']
else:
! # call to a service method
try:
direntry = self.getMethodDirEntry(method)
server_method = direntry['binding']
signature=direntry['signature']
! if server_method==None:
raise AttributeError, \
! _("Server XML-RPC method %s is not ") +\
! _("bound to real method") % method
except KeyError:
raise AttributeError, \
_("Server does not have XML-RPC ") +\
! _("procedure %s") % method
try:
#
pass
--- 188,236 ----
_("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:
! 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
!
direntry = self.getMethodDirEntry(o._type+"."+method)
signature=direntry['signature']
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
***************
*** 215,220 ****
--- 239,245 ----
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
***************
*** 231,239 ****
pass
counter=counter+1;
! # call method with params
! result=server_method(*params)
# replace real object in param with an object handle
if type(result)==type(self): ## both should be instances
--- 256,290 ----
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)
!
! 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/common/src/commdrivers xmlrpc/ServerAdapte...,
Jan Ischebeck <=