ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/xmlrpctest/xmlrpcserver.py
Revision: 1.1
Committed: Sun Nov 9 21:02:45 2003 UTC (20 years, 3 months ago) by ajm
Content type: text/x-python
Branch: MAIN
Log Message:
initial checkin of some play code

File Contents

# User Rev Content
1 ajm 1.1 #!/usr/bin/python
2     #
3     # Experiments with Pythons XML-RPM implementation
4     # - the server
5     #
6     # $Id$
7    
8     from SimpleXMLRPCServer import *
9    
10     class ServerImpl(SimpleXMLRPCServer):
11    
12     def serve_forever(self):
13     print '[server] starting up'
14     self.quit = 0
15     while not self.quit:
16     self.handle_request()
17    
18     print '[server] shutting down'
19     self.socket.close()
20    
21     class ServerFunctions:
22    
23     # we pass in a ref to the server
24     # that these functions will be used in
25     # so they can interact...I'm guessing
26     # this is clean?...who knows :)
27     def __init__(self, server):
28     self.server = server
29    
30     def die(self):
31     """die() => kills the server"""
32     self.server.quit = 1
33     return 1
34    
35     def remoteprint(self, text):
36     """print('HelloWorld') => prints HelloWorld"""
37     print '[server] got:', text
38     return 1
39    
40     def main():
41     print '--- i-scream.org XML-RPC test server ---'
42    
43     server = ServerImpl(('127.0.0.1', 8000), logRequests=0)
44     server.register_instance(ServerFunctions(server))
45     server.register_introspection_functions()
46     server.register_multicall_functions()
47     server.serve_forever()
48    
49     if __name__=='__main__':
50     main()