diff doc/xmlrpc.txt @ 6342:31bac6f2dd8b

Update advanced script to python3; other doc updates
author John Rouillard <rouilj@ieee.org>
date Sat, 13 Mar 2021 21:48:59 -0500
parents 81ae33038ec5
children 45e8d10a9609
line wrap: on
line diff
--- a/doc/xmlrpc.txt	Sat Mar 13 11:03:42 2021 -0500
+++ b/doc/xmlrpc.txt	Sat Mar 13 21:48:59 2021 -0500
@@ -79,8 +79,8 @@
 
 Client API
 ----------
-The server currently implements four methods. Each method requires
-that the user provide a username and password in the HTTP
+The server currently implements seven methods/commands. Each method
+requires that the user provide a username and password in the HTTP
 authorization header in order to authenticate the request against the
 tracker.
 
@@ -128,7 +128,8 @@
         ``list`` is a list of ids to filter. It can be set to None to run
         filter over all values (requires ``allow_none=True`` when
         instantiating the ServerProxy). The ``attributes`` are given as a 
-        dictionary of name value pairs to search for. See also :ref:`query-tracker`.
+        dictionary of name value pairs to search for. See also
+        :ref:`query-tracker`.
 ======= ====================================================================
 
 sample python client
@@ -173,35 +174,45 @@
 from the server and reports it. Note if you are using http rather than
 https, replace xmlrpclib.SafeTransport with xmlrpclib.Transport::
 
-    import xmlrpclib
+    try:
+        from xmlrpc import client as xmlrpclib  # python 3
+    except ImportError:
+        import xmlrpclib  # python 2
+
+    hostname="localhost"
+    path="/demo"
+    user_pw="admin:admin"
 
     class SpecialTransport(xmlrpclib.SafeTransport):
 
-	def send_content(self, connection, request_body):
+        def send_content(self, connection, request_body):
 
-	    connection.putheader("Referer", "https://localhost/demo/")
-	    connection.putheader("Origin", "https://localhost")
-	    connection.putheader("X-Requested-With", "XMLHttpRequest")
+            connection.putheader("Referer", "https://%s%s/"%(hostname, path))
+            connection.putheader("Origin", "https://%s"%hostname)
+            connection.putheader("X-Requested-With", "XMLHttpRequest")
 
-	    connection.putheader("Content-Type", "text/xml")	
-	    connection.putheader("Content-Length", str(len(request_body)))
-	    connection.endheaders()
-	    if request_body:
-		connection.send(request_body)
+            connection.putheader("Content-Type", "text/xml")    
+            connection.putheader("Content-Length", str(len(request_body)))
+            connection.endheaders()
+            if request_body:
+                connection.send(request_body)
 
     roundup_server = xmlrpclib.ServerProxy(
-	'https://admin:admin@localhost/demo/xmlrpc',
-	transport=SpecialTransport(),
-	verbose=False,
-	allow_none=True)
+        'https://%s@%s%s/xmlrpc'%(user_pw,hostname,path),
+        transport=SpecialTransport(),
+        verbose=False,
+        allow_none=True)
 
     print(roundup_server.schema())
     print(roundup_server.display('user2', 'username'))
     print(roundup_server.display('issue1', 'status'))
     print(roundup_server.filter('user',['1','2','3'],{'username':'demo'}))
 
-   # this will fail with a fault
-   try:
-      print(roundup_server.filter('usr',['0','2','3'],{'username':'demo'}))
-   except Exception as msg:
-      print(msg)
+    # this will fail with a fault
+    try:
+        print(roundup_server.filter('usr',['0','2','3'],{'username':'demo'}))
+    except Exception as msg:
+        print(msg)
+
+modify this script replacing the hostname, path and user_pw with those
+for your tracker.

Roundup Issue Tracker: http://roundup-tracker.org/