16 |
# write to the Free Software Foundation, Inc., 59 Temple Place |
# write to the Free Software Foundation, Inc., 59 Temple Place |
17 |
# - Suite 330, Boston, MA 02111-1307, USA. |
# - Suite 330, Boston, MA 02111-1307, USA. |
18 |
# |
# |
19 |
# Copyright 2001 Free Software Foundation |
# Copyright 2001-2003 Free Software Foundation |
20 |
# |
# |
21 |
# FILE: |
# FILE: |
22 |
# xmlrpc/ServerAdapter.py |
# xmlrpc/ServerAdapter.py |
64 |
from xmlrpclib import xmlrpclib |
from xmlrpclib import xmlrpclib |
65 |
|
|
66 |
except ImportError: |
except ImportError: |
67 |
raise GComm.AdapterInitializationError, \ |
tmsg = _("\nUnable to load xmlrpclib. To use the XML-RPC interface, \n") \ |
|
_("\nUnable to load xmlrpclib. To use the XML-RPC interface, \n") \ |
|
68 |
+ _("please install xmlrpc from:\n") \ |
+ _("please install xmlrpc from:\n") \ |
69 |
+ " http://www.pythonware.com/products/xmlrpc/" |
+ " http://www.pythonware.com/products/xmlrpc/" |
70 |
|
raise GComm.AdapterInitializationError, tmsg |
71 |
|
|
72 |
|
|
73 |
# Mapping from GRPC's datatype to XML-RPC datatypes |
# Mapping from GRPC's datatype to XML-RPC datatypes |
117 |
try: |
try: |
118 |
self._port = params['port'] |
self._port = params['port'] |
119 |
except KeyError: |
except KeyError: |
120 |
raise GComm.AdapterConfigurationError, _('Required parameter "port" not supplied') |
tmsg = _('Required parameter "port" not supplied') |
121 |
|
raise GComm.AdapterConfigurationError, tmsg |
122 |
|
|
123 |
if hasattr(params,'loglevel'): |
if hasattr(params,'loglevel'): |
124 |
self._loglevel = params['loglevel'] |
self._loglevel = params['loglevel'] |
183 |
objhandle=method[1:i] |
objhandle=method[1:i] |
184 |
method=method[i+2:] |
method=method[i+2:] |
185 |
except ValueError: |
except ValueError: |
186 |
raise AttributeError, \ |
tmsg = _("Wrong format of object handle ")+\ |
|
_("Wrong format of object handle ")+\ |
|
187 |
_("in method call %s") % method |
_("in method call %s") % method |
188 |
|
raise AttributeError, tmsg |
189 |
# TODO check in service dir, if obj is supported or not |
# TODO check in service dir, if obj is supported or not |
190 |
o=ObjectLibrarian.retrieveObject(objhandle) |
o=ObjectLibrarian.retrieveObject(objhandle) |
191 |
try: |
try: |
230 |
signature=direntry['signature'] |
signature=direntry['signature'] |
231 |
|
|
232 |
if (server_method==None) and (server_attribute==None): |
if (server_method==None) and (server_attribute==None): |
233 |
raise AttributeError, \ |
tmsg = _("Server XML-RPC method %s is not ")% method +\ |
|
_("Server XML-RPC method %s is not ")% method +\ |
|
234 |
_("bound to real method") |
_("bound to real method") |
235 |
|
raise AttributeError, tmsg |
236 |
except KeyError: |
except KeyError: |
237 |
raise AttributeError, \ |
tmsg = _("Server does not have XML-RPC ") +\ |
|
_("Server does not have XML-RPC ") +\ |
|
238 |
_("procedure %s") % method |
_("procedure %s") % method |
239 |
|
raise AttributeError, tmsg |
240 |
try: |
try: |
241 |
# |
# |
242 |
pass |
pass |
243 |
# TODO: Compare submitted attributs with signature |
# TODO: Compare submitted attributs with signature |
244 |
except KeyError: |
except KeyError: |
245 |
raise AttributeError, \ |
tmsg = _("Server XML-RPC ") +\ |
|
_("Server XML-RPC ") +\ |
|
246 |
_("procedure %s accepts just %s as attributs") % (method,attr) |
_("procedure %s accepts just %s as attributs") % (method,attr) |
247 |
|
raise AttributeError, tmsg |
248 |
|
|
249 |
|
|
250 |
# replace object handles in param with the real object |
# replace object handles in param with the real object |
291 |
# getAttribut method |
# getAttribut method |
292 |
result=server_attribute |
result=server_attribute |
293 |
else: |
else: |
294 |
raise AttributeError, \ |
tmsg = _("Internal Server XML-RPC error: method type") +\ |
|
_("Internal Server XML-RPC error: method type") +\ |
|
295 |
_("(get/set attribute) couldn't be detected (method %s)") \ |
_("(get/set attribute) couldn't be detected (method %s)") \ |
296 |
% method |
% method |
297 |
|
raise AttributeError, tmsg |
298 |
|
|
299 |
|
|
300 |
# replace real object in param with an object handle |
# replace real object in param with an object handle |
449 |
del args['obj_handle'] |
del args['obj_handle'] |
450 |
|
|
451 |
except KeyError: |
except KeyError: |
452 |
raise StandardError, _('Object handle not returned') # TODO |
tmsg = _('Object handle not returned') |
453 |
|
raise StandardError, tmsg # TODO |
454 |
|
|
455 |
try: |
try: |
456 |
return ObjectLibrarian. \ |
return ObjectLibrarian. \ |
458 |
except KeyError: |
except KeyError: |
459 |
|
|
460 |
# Attempt to use an invalid objecthandle |
# Attempt to use an invalid objecthandle |
461 |
raise StandardError, _('Invalid object handle') # TODO |
tmsg = _('Invalid object handle') |
462 |
|
raise StandardError, tmsg # TODO |
463 |
|
|
464 |
|
|
465 |
|
|