#!/usr/home/sweetapp/bin/python

"""
This script is meant to test the Python XML-RPC server classes
using the XML-RPC validator found at http://validator.xmlrpc.com/
"""

import cgitb; cgitb.enable()
from DocXMLRPCServer import DocCGIXMLRPCRequestHandler

def arrayOfStructsTest(a):
    
ncurlies = 0
    
for s in a:
        
ncurlies = ncurlies + s.get("curly", 0)
    
return ncurlies

def countTheEntities(s):
    
return {'ctLeftAngleBrackets': s.count('<'),
            
'ctRightAngleBrackets': s.count('>'),
            
'ctAmpersands': s.count('&'),
            
'ctApostrophes': s.count("'"),
            
'ctQuotes': s.count('"')}
    
def easyStructTest(s):
    
return (s.get("moe", 0)
            
+ s.get("larry", 0)
            
+ s.get("curly", 0))

def echoStructTest(s):
    
return s

def manyTypesTest(num,bool,s,doub,dateTime,base64):
    
return [num, bool, s, doub, dateTime,base64]

def moderateSizeArrayCheck(array):
    
return array[0] + array[-1]

def nestedStructTest(s):
    
s = s['2000']['04']['01']
    
return (s.get("moe", 0)
            
+ s.get("larry", 0)
            
+ s.get("curly", 0))

def simpleStructReturnTest(number):
    
return {'times10': number * 10,
            
'times100': number * 100,
            
'times1000': number * 1000}

handler = DocCGIXMLRPCRequestHandler()
handler.register_introspection_functions()
handler.register_multicall_functions()
handler.set_server_name('Conformance suite')
handler.set_server_title('Conformance suite')
handler.set_server_documentation(__doc__)
handler.register_function(arrayOfStructsTest, 'validator1.arrayOfStructsTest')
handler.register_function(countTheEntities, 'validator1.countTheEntities')
handler.register_function(easyStructTest, 'validator1.easyStructTest')
handler.register_function(echoStructTest, 'validator1.echoStructTest')
handler.register_function(manyTypesTest, 'validator1.manyTypesTest')
handler.register_function(moderateSizeArrayCheck, 'validator1.moderateSizeArrayCheck')
handler.register_function(nestedStructTest, 'validator1.nestedStructTest')
handler.register_function(simpleStructReturnTest, 'validator1.simpleStructReturnTest')
handler.handle_request()

Download
The source was styled using SilverCity