ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/xmlrpctest/xmlrpcserver.py
Revision: 1.2
Committed: Sun Nov 9 22:20:21 2003 UTC (20 years, 11 months ago) by ajm
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +5 -5 lines
Log Message:
more 2.3 style booleans

File Contents

# Content
1 #!/usr/bin/python
2 #
3 # Experiments with Pythons XML-RPC implementation
4 # - the server
5 #
6 # $Id: xmlrpcserver.py,v 1.1 2003/11/09 21:02:45 ajm Exp $
7
8 from SimpleXMLRPCServer import *
9
10 class ServerImpl(SimpleXMLRPCServer):
11
12 def serve_forever(self):
13 print '[server] starting up'
14 self.run = True
15 while self.run:
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.run = False
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()