Index: doc/howto/xmlrpc.html =================================================================== RCS file: /cvs/Twisted/doc/howto/xmlrpc.html,v retrieving revision 1.11 diff -u -r1.11 xmlrpc.html --- doc/howto/xmlrpc.html 19 Jul 2003 12:42:34 -0000 1.11 +++ doc/howto/xmlrpc.html 26 Aug 2003 05:33:34 -0000 @@ -86,6 +86,57 @@ xmlquote.rpy +
XML-RPC resource can be nested so that one handler calls another if
+a method with a given prefix is called. For example, to add support for
+an XML-RPC method called 'date.time' to the Example
+class, you could do the following:
+
+import time
+from twisted.web import xmlrpc, server
+
+class Example(xmlrpc.XMLRPC):
+ """An example object to be published."""
+
+ def xmlrpc_echo(self, x):
+ """Return all passed args."""
+ return x
+
+ def xmlrpc_add(self, a, b):
+ """Return sum of arguments."""
+ return a + b
+
+class Date(xmlrpc.XMLRPC):
+ """Serve the XML-RPC 'time' method."""
+
+ def xmlrpc_time(self):
+ """Return UNIX time."""
+ return time.time()
+
+def main():
+ from twisted.internet.app import Application
+ app = Application("xmlrpc")
+ r = Example()
+ date = Date()
+ r.putSubHandler('date', date)
+ app.listenTCP(7080, server.Site(r))
+ return app
+
+application = main()
+
+if __name__ == '__main__':
+ application.run(save=0)
+
+
+By default, a period ('.') separates the prefix from the method
+name, but you can use a different character by overriding the XMLRPC.separator data member in your base
+XML-RPC server. XML-RPC servers may be nested to arbitrary depths
+using this method.
From the point of view, of a Twisted developer, there is little difference @@ -166,4 +217,3 @@