[mod_python] onunload ie mod_python

Graham Dumpleton grahamd at dscpl.com.au
Thu Oct 27 06:03:12 EDT 2005

On 27/10/2005, at 6:31 AM, Nick wrote:

> See also  
> http://developer.apple.com/internet/webcontent/xmlhttpreq.html for  
> another solution (there are many resources for this information, but I  
> like that one best).
> SimpleXMLRPCServer is a standard module in Python, and I don't think  
> it's as complex as you might think, but the above solution might yield  
> quicker results for you.

As far as integrating XML-RPC into mod_python, you are possibly better
of using the xmlrpclib.dumps() and xmlrpclib.loads() functions directly.
 From memory this gives better control over handling errors. At least
I know I had a good reason at the time which I can't think of right now.
Possibly because overriding SimpleXmlRpcServer didn't provide a good
way of returning a 404 when function didn't exist.

For an example of using xmlrpclib module direct, see serviceRequest()
function in code file at:


This is brief, but leaves dispatch to a particular function up to
a callback. Mapping partial URLs below a specific point in URL
hierarchy is a bit more tricky to get right correctly, especially
avoiding exposing Python internals that should be hidden.

The XML-RPC service wrapper object provides a simple way of doing
this, eg:


Where mod_python is a bit of a pain is that a lot of people use
mod_python.publisher and integrating an XML-RPC service against a
specific published resource when using mod_python.publisher can't
be done due to a limitation in mod_python.publisher. See:


In the Vampire version of publisher where this problem is fixed, one
can use the vampire.Service() wrapper in conjunction with published
functions. For example, you might have a published module with:

   class _Object:

     def method1(self):
       return "method1"

     def method2(self,req):
       return "method2"

     def method3(self,req,arg):
       return "method3"

   object = _Object()

   object_as_xmlrpc = vampire.Service(form)

Thus URL "object/method1", "object/method2" and "object/method3" act
like normal published functions with form arguments as appropriate.
Use the URL "object_as_xmlrpc/method1", etc, then it interprets the
request as an XML-RPC call, with the target being the same functions
as also accessible as standard GET/POST requests. This just can't
be done with mod_python.publisher as it stands as it doesn't pay
attention to content type and only interpret POST requests as form
requests when it is actually one. Ie., at the moment it would try
and consume the content of the XML-RPC request as a form post.

Anyway, enough ranting about it how it would be nice to see this
aspect of mod_python.publisher fixed. At least i don't believe it
is fixed in 3.2. :-)

That all said, even if XML-RPC is easy to implement on the server
side with mod_python, I would probably suggest that when he says
it isn't easy, it refers more to the client side in the browser.


More information about the Mod_python mailing list