The XMLRPCController class is accessible via the pylons.controllers.xmlrpc module.
This controller handles XML-RPC responses and complies with the XML-RPC Specification as well as the XML-RPC Introspection specification.
By default, methods with names containing a dot are translated to use an underscore. For example, the system.methodHelp is handled by the method system_methodHelp .
Methods in the XML-RPC controller will be called with the method given in the XMLRPC body. Methods may be annotated with a signature attribute to declare the valid arguments and return types.
For example:
class MyXML(XMLRPCController):
def userstatus(self):
return 'basic string'
userstatus.signature = [ ['string'] ]
def userinfo(self, username, age=None):
user = LookUpUser(username)
response = {'username':user.name}
if age and age > 10:
response['age'] = age
return response
userinfo.signature = [['struct', 'string'],
['struct', 'string', 'int']]
Since XML-RPC methods can take different sets of data, each set of valid arguments is its own list. The first value in the list is the type of the return argument. The rest of the arguments are the types of the data that must be passed in.
In the last method in the example above, since the method can optionally take an integer value both sets of valid parameter lists should be provided.
Valid types that can be checked in the signature and their corresponding Python types:
'string' - str 'array' - list 'boolean' - bool 'int' - int 'double' - float 'struct' - dict 'dateTime.iso8601' - xmlrpclib.DateTime 'base64' - xmlrpclib.Binary
The class variable allow_none is passed to xmlrpclib.dumps; enabling it allows translating None to XML (an extension to the XML-RPC specification)
Note:
Requiring a signature is optional.
Parse an XMLRPC body for the method, and call it with the appropriate arguments
Calls a function with arguments from _get_method_args
Given a function, inspect_call will inspect the function args and call it with no further keyword args than it asked for.
If the function has been decorated, it is assumed that the decorator preserved the function signature.
See the source for more information.