[Zope-Checkins] CVS: Zope/lib/python - xmlrpclib.py:1.8
Toby Dickenson
tdickenson@geminidataloggers.com
Fri, 31 May 2002 08:32:01 -0400
Update of /cvs-repository/Zope/lib/python
In directory cvs.zope.org:/tmp/cvs-serv29360
Modified Files:
xmlrpclib.py
Log Message:
fixed line endings
=== Zope/lib/python/xmlrpclib.py 1.7 => 1.8 === (1607/1707 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/products/xml/sgmlop.htm
-#
-# this version is designed to work with Python 1.5.2 or newer.
-# unicode encoding support requires at least Python 1.6.
-# experimental HTTPS requires Python 2.0 built with SSL sockets.
-#
-# 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 parsers/transports (0.9.8)
-# 2000-11-28 fl Changed boolean to check the truth value of its argument
-# 2001-02-24 fl Added encoding/Unicode/SafeTransport patches
-# 2001-02-26 fl Added compare support to wrappers (0.9.9)
-#
-# Copyright (c) 1999-2001 by Secret Labs AB.
-# Copyright (c) 1999-2001 by Fredrik Lundh.
-#
-# fredrik@pythonware.com
-# http://www.pythonware.com
-#
-# --------------------------------------------------------------------
-# The XML-RPC client interface is
-#
-# Copyright (c) 1999-2001 by Secret Labs AB
-# Copyright (c) 1999-2001 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
[-=- -=- -=- 1607 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