SimpleXMLRPCServer question

rdmurray at rdmurray at
Sat Jan 31 23:25:31 CET 2009

Quoth flagg <ianand0204 at>:
> Let me see if i can elaborate on the requirements.  I have 20+
> different zone files.  I want the xmlrpc server to be able to
> determine what zone file to open by looking at the incoming xml
> request.  For example one of the functions I have now is to show a DNS
> record (I am using dnspython for most of this work)
> If i send an xmlrpc request that uses the 'showRecord' function with
> params of ''  I want to parse the "params" piece
> and then instruct the xml-rpc server to open for
> reading.  The reason why i was looking at do_Post() and _dispatch was
> to attempt to read the incoming params and do exactly that.
> Do you think there is an easier way of accomplishing this, than the
> way I am going about it?

Yeah.  Take a look at the SimpleXLMRPC documentation:

In addition to setting up the server as instructed (let's assume you
assign it to the variable 'server'), you just need to do something like:

    class MyFunctions:

        def showRecord(self, dnsname):
            domain = '.'.join(dnsname.split('.')[1:])
            with open(domain+'.zone')) as myfile:
                # do stuff with data from myfile


You would modify the body of that function to meet your processing
requirements, of course.  That is, SimpleXMLRPCServer does the request
parsing for you, calls the correspondingly named method, and passes it
the params as method arguments.

(This example is taken from the SimpleXMLRPC documentation, I just
selected one particular way of exposing the methods: via a class


More information about the Python-list mailing list