[Zope-Checkins] CVS: Zope/lib/python - xmlrpclib.py:1.6.132.1

Toby Dickenson tdickenson@geminidataloggers.com
Fri, 31 May 2002 06:21:32 -0400


Update of /cvs-repository/Zope/lib/python
In directory cvs.zope.org:/tmp/cvs-serv28643

Modified Files:
      Tag: toby-xmlrpclib099-branch
	xmlrpclib.py 
Log Message:
update to xmlrpclib 0.9.9 from www.pythonware.com

=== Zope/lib/python/xmlrpclib.py 1.6 => 1.6.132.1 === (1409/1509 lines abridged)
-# XML-RPC CLIENT LIBRARY
-# $Id$
-#
-# an XML-RPC client interface for Python.
-#
-# the marshalling and response parser code can also be used to
-# implement XML-RPC servers.
-#
-# Notes:
-# this version uses the sgmlop XML parser, if installed.  this is
-# typically 10-15x faster than using Python's standard XML parser.
-#
-# you can get the sgmlop distribution from:
-#
-#    http://www.pythonware.com/madscientist
-#
-# also note that this version is designed to work with Python 1.5.1
-# or newer.  it doesn't use any 1.5.2-specific features.
-#
-# History:
-# 1999-01-14 fl  Created
-# 1999-01-15 fl  Changed dateTime to use localtime
-# 1999-01-16 fl  Added Binary/base64 element, default to RPC2 service
-# 1999-01-19 fl  Fixed array data element (from Skip Montanaro)
-# 1999-01-21 fl  Fixed dateTime constructor, etc.
-# 1999-02-02 fl  Added fault handling, handle empty sequences, etc.
-# 1999-02-10 fl  Fixed problem with empty responses (from Skip Montanaro)
-# 1999-06-20 fl  Speed improvements, pluggable XML parsers and HTTP transports
-#
-# Copyright (c) 1999 by Secret Labs AB.
-# Copyright (c) 1999 by Fredrik Lundh.
-#
-# fredrik@pythonware.com
-# http://www.pythonware.com
-#
-# --------------------------------------------------------------------
-# The XML-RPC client interface is
-# 
-# Copyright (c) 1999 by Secret Labs AB
-# Copyright (c) 1999 by Fredrik Lundh
-# 
-# By obtaining, using, and/or copying this software and/or its
-# associated documentation, you agree that you have read, understood,
-# and will comply with the following terms and conditions:
-#
-# Permission to use, copy, modify, and distribute this software and
-# its associated documentation for any purpose and without fee is
-# hereby granted, provided that the above copyright notice appears in
-# all copies, and that both that copyright notice and this permission
-# notice appear in supporting documentation, and that the name of

[-=- -=- -=- 1409 lines omitted -=- -=- -=-]

+        self.__verbose = verbose
+
+    def __request(self, methodname, params):
+        # call a method on the remote server
+
+        request = dumps(params, methodname, encoding=self.__encoding)
+
+        response = self.__transport.request(
+            self.__host,
+            self.__handler,
+            request,
+            verbose=self.__verbose
+            )
+
+        if len(response) == 1:
+            response = response[0]
+
+        return response
+
+    def __repr__(self):
+        return (
+            "<Server proxy for %s%s>" %
+            (self.__host, self.__handler)
+            )
+
+    __str__ = __repr__
+
+    def __getattr__(self, name):
+        # magic method dispatcher
+        return _Method(self.__request, name)
+
+    # note: to call a remote object with an non-standard name, use
+    # result getattr(server, "strange-python-name")(args)
+
+# --------------------------------------------------------------------
+# test code
+
+if __name__ == "__main__":
+
+    # simple test program (from the XML-RPC specification)
+
+    # server = Server("http://localhost:8000") # local server
+    server = Server("http://betty.userland.com")
+
+    print server
+
+    try:
+        print server.examples.getStateName(41)
+    except Error, v:
+        print "ERROR", v