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

Martijn Pieters mj@zope.com
Thu, 29 Aug 2002 11:21:03 -0400


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

Modified Files:
	xmlrpclib.py 
Log Message:
Update xmlrpclib.py to the Python2.2 version, while preserving the Zope
specific addition of marshalling None to <boolean>0</boolean>.

Benefits gained:

  - Uses Expat when available (like in Zope), which makes unmarshalling
    (receiving XML-RPC calls) much,much faster.

  - New library imports other python modules lazily, which helps speed up
    Zope startup time.

  - Faster escape method for outgoing calls.

  - Fixes for doubles and larger integers.

  - Allow XML-RPC calls without an empty <params /> (fixes Zope Collector
    #465)

Additional fix:

  - Fix SlowParser to handle CDATA sections as well. With the ExpatParser
    this is less of a problem (fixes Zope Collector #547). Also see Python
    SF issue #601534.


=== Zope/lib/python/xmlrpclib.py 1.10 => 1.11 === (719/819 lines abridged)
--- Zope/lib/python/xmlrpclib.py:1.10	Wed Jul 10 05:59:11 2002
+++ Zope/lib/python/xmlrpclib.py	Thu Aug 29 11:21:00 2002
@@ -8,16 +8,10 @@
 # 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.
+# expat parser support requires Python 2.0 with pyexpat support.
 #
 # History:
 # 1999-01-14 fl  Created
@@ -30,12 +24,23 @@
 # 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)
+# 2001-02-26 fl  Added compare support to wrappers (0.9.9/1.0b1)
+# 2001-03-28 fl  Make sure response tuple is a singleton
+# 2001-03-29 fl  Don't require empty params element (from Nicholas Riley)
+# 2001-06-10 fl  Folded in _xmlrpclib accelerator support (1.0b2)
+# 2001-08-20 fl  Base xmlrpclib.Error on built-in Exception (from Paul Prescod)
+# 2001-09-03 fl  Allow Transport subclass to override getparser
+# 2001-09-10 fl  Lazy import of urllib, cgi, xmllib (20x import speedup)
+# 2001-10-01 fl  Remove containers from memo cache when done with them
+# 2001-10-01 fl  Use faster escape method (80% dumps speedup)
+# 2001-10-10 sm  Allow long ints to be passed as ints if they don't overflow
+# 2001-10-17 sm  test for int and long overflow (allows use on 64-bit systems)
+# 2001-11-12 fl  Use repr() to marshal doubles (from Paul Felix)
 #
 # Copyright (c) 1999-2001 by Secret Labs AB.
 # Copyright (c) 1999-2001 by Fredrik Lundh.
 #
-# fredrik@pythonware.com
+# info@pythonware.com
 # http://www.pythonware.com
 #
 # --------------------------------------------------------------------
@@ -68,34 +73,62 @@
 # --------------------------------------------------------------------
 
 #

[-=- -=- -=- 719 lines omitted -=- -=- -=-]

 
     def make_connection(self, host):
         # create a HTTPS connection object from a host descriptor
@@ -760,7 +927,7 @@
             host, x509 = host
         connection.putheader("Host", host)
 
-class Server:
+class ServerProxy:
     """uri [,options] -> a logical connection to an XML-RPC server
 
     uri is the connection point on the server, given as
@@ -786,6 +953,7 @@
         # establish a "logical" server connection
 
         # get the url
+        import urllib
         type, uri = urllib.splittype(uri)
         if type not in ("http", "https"):
             raise IOError, "unsupported XML-RPC protocol"
@@ -822,7 +990,7 @@
 
     def __repr__(self):
         return (
-            "<Server proxy for %s%s>" %
+            "<ServerProxy for %s%s>" %
             (self.__host, self.__handler)
             )
 
@@ -835,6 +1003,9 @@
     # note: to call a remote object with an non-standard name, use
     # result getattr(server, "strange-python-name")(args)
 
+# compatibility
+Server = ServerProxy
+
 # --------------------------------------------------------------------
 # test code
 
@@ -842,8 +1013,8 @@
 
     # simple test program (from the XML-RPC specification)
 
-    # server = Server("http://localhost:8000") # local server
-    server = Server("http://betty.userland.com")
+    # server = ServerProxy("http://localhost:8000") # local server
+    server = ServerProxy("http://betty.userland.com")
 
     print server