This might seem easy enough, but it took me a while to get it right since the Pylons documentation is a bit misleading here, really. It says you should use xmlrpc_fault from pylons.controllers.xmlrpc but that’s actually not working if you’re doing something like:

from pylons.controllers.xmlrpc import xmlrpc_fault
return xmlrpc_fault( 101, "My Error" )

This will wrap an xmlrpclib.Fault into a pylons.controllers.util.Reponse object which will fail to marshal with something like:

TypeError: cannot marshal objects

The correct way to do it is:

import xmlrpclib
return xmlrpclib.Fault( 101, "My Error" )

Leave a comment