XML-RPC "filter"

Luigi luigipaioro at libero.it
Tue Sep 9 17:53:57 CEST 2008

Dear all,

I'm writing an XML-RPC server which should be able to modify the
incoming request before dispatching it. In particular I wand to added
two fixed parameters to the method called: one is the client host
address, and the other is the user name provided as for Basic
Authentication (http://user@www.bla-bla.com).

To do this, at the present I've overwritten the do_POST method of
SimpleXMLRPCRequestHandler, including at a certain point this code:

data = ''.join(L)

params, method = xmlrpclib.loads(data)
user = "unknown"
if self.headers.has_key('Authorization'):
  # handle Basic authentication
  (enctype, encstr) =  self.headers.get('Authorization').split()
  user, password = base64.standard_b64decode(encstr).split(':')
params = list(params)
params = tuple(params)
data = xmlrpclib.dumps(params, methodname=method)

(I slightly modified it to make it more readable at mail level)

It works, but I don't really like it because it completely overwrites
the do_POST method that in the future Python releases is going to
change (I verified it). Do you know a better way to do this?

Thanks in advance.


More information about the Python-list mailing list