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:
|
1 2 3 |
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:
|
1 2 |
TypeError: cannot marshal <class 'pylons.controllers.util.Response'> objects
</class> |
The correct way to do it is:
|
1 2 3 |
import xmlrpclib
...
return xmlrpclib.Fault( 101, "My Error" ) |