[Zope3-checkins] CVS: Zope3/src/zope/publisher - xmlrpc.py:1.9

Stephan Richter srichter at cosmos.phy.tufts.edu
Mon Aug 4 20:19:57 EDT 2003


Update of /cvs-repository/Zope3/src/zope/publisher
In directory cvs.zope.org:/tmp/cvs-serv1822/src/zope/publisher

Modified Files:
	xmlrpc.py 
Log Message:
After wanting to fix XML-RPC for over a year, I finally got around to do
it. You can now specify view names, create default views and of course you
do not have access to the object's methods directly anymore.

Added some tests for all of this.

Updated XML-RPC directives. Made them also a bit more consistent with the 
browser ones.

This should make the XML-RPC code ready for the beta.


=== Zope3/src/zope/publisher/xmlrpc.py 1.8 => 1.9 ===
--- Zope3/src/zope/publisher/xmlrpc.py:1.8	Wed Jun  4 05:09:45 2003
+++ Zope3/src/zope/publisher/xmlrpc.py	Mon Aug  4 19:19:23 2003
@@ -11,12 +11,16 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
+"""XML-RPC Publisher
+
+This module contains the MethodPublisher, XMLRPCView, XMLRPCRequest and
+XMLRPCResponse
 
 $Id$
 """
 import sys
 import xmlrpclib
+from StringIO import StringIO
 
 from zope.interface import implements
 from zope.publisher.interfaces.xmlrpc import IXMLRPCPublisher
@@ -28,13 +32,12 @@
 from zope.publisher.http import DefaultPublisher
 from zope.proxy import removeAllProxies
 
-__metaclass__ = type # All classes are new style when run with Python 2.2+
+__metaclass__ = type
 
 
 class MethodPublisher(DefaultPublisher):
     """Simple XML-RPC publisher that is identical to the HTTP Default Publisher
-       except that it implements the IXMLRPCPublisher interface.
-    """
+       except that it implements the IXMLRPCPublisher interface."""
 
     implements(IXMLRPCPublisher)
 
@@ -43,6 +46,16 @@
         self.request = request
 
 
+class XMLRPCView:
+    """A base XML-RPC view that can be used as mix-in for XML-RPC views.""" 
+
+    implements(IXMLRPCView)
+
+    def __init__(self, context, request):
+        self.context = context
+        self.request = request
+
+
 class XMLRPCRequest(HTTPRequest):
 
     implements(IXMLRPCPublication)
@@ -86,7 +99,6 @@
         if kw:
             _testEnv.update(kw)
         if body_instream is None:
-            from StringIO import StringIO
             body_instream = StringIO('')
 
         if outstream is None:
@@ -97,9 +109,10 @@
 
 
 class XMLRPCResponse(HTTPResponse):
-    """XMLRPC response
-    """
+    """XMLRPC response.
 
+    This object is responsible for converting all output to valid XML-RPC.
+    """
 
     def setBody(self, body):
         """Sets the body of the response
@@ -163,12 +176,3 @@
         # Do the damage.
         self.setBody(fault_text)
         self.setStatus(200)
-
-
-class XMLRPCView:
-
-    implements(IXMLRPCView)
-
-    def __init__(self, context, request):
-        self.context = context
-        self.request = request




More information about the Zope3-Checkins mailing list