[mod_python] XML-RPC?

Michael mogmios at mlug.missouri.edu
Sun Feb 29 03:45:49 EST 2004


Having looked further at this it seems to be caused any time

xmlrpclib.loads() is used inside a mod_python handler. Even when the 
data being sent to loads() isn't being read() from the client. The same 
code ran from the command line does not raise an error. I can run the 
code with mod_python imported though. Is there some bad interaction 
between Apache, mod_python, and xmlrpclib (or prehaps one of it's parsers)?

> Any idea what I'm doing wrong here? I've tried both just pasting this 
> HTTP data to the server and using the below client code to make the 
> connection. Either way I get a ResponseError from the server code - 
> from the xmlrpclib. If I have the server print the POST data it has 
> read it looks correct. If I paste the POST data from that into a 
> Python script and run it through xmlrpclib.loads() it works fine. What 
> is wrong?
>
> client
> ------
> server = xmlrpclib.ServerProxy ( 'http://localhost/mike.py', verbose = 
> True )
>
> try:
>        print server.testing ( 41 )
> except xmlrpclib.Error, e:
>        print 'ERROR:', e
>
>
> server
> ------
> def handler ( req ):
>        req.content_type = "text/xml"
>        req.send_http_header ()
>        data = req.read ()
>        try:
>                params, method = xmlrpclib.loads ( data )
>        except xmlrpclib.ResponseError, e:
>                req.write ( xmlrpclib.dumps ( e ) )
>        return apache.OK
>
>
>>> I want to use Mod_Python to implement an XML-RPC server. Am I right 
>>> in trying to use CGIXMLRPCRequestHandler for that? How do I get the 
>>> POST data from Mod_Python so I can run it through the XML-RPC 
>>> handler? Thanks.
>>>   
>>
>>
>> I use xmlrpclib together with the xmlrpc_registry (by Eric Kidd), but I
>> guess it works for any xmlrpc handler.
>>
>> params, method = xmlrpclib.loads(req.read())
>



More information about the Mod_python mailing list