[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/XMLRPC - IXMLRPCPresentation.py:1.1 IXMLRPCPublication.py:1.1 IXMLRPCView.py:1.1 XMLRPCView.py:1.1 IXMLRPCPublisher.py:1.3 XMLRPCRequest.py:1.3 XMLRPCResponse.py:1.3
Stephan Richter
srichter@cbu.edu
Sun, 16 Jun 2002 14:40:25 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/XMLRPC
In directory cvs.zope.org:/tmp/cvs-serv26330/Publisher/XMLRPC
Modified Files:
IXMLRPCPublisher.py XMLRPCRequest.py XMLRPCResponse.py
Added Files:
IXMLRPCPresentation.py IXMLRPCPublication.py IXMLRPCView.py
XMLRPCView.py
Log Message:
Okay, someone refactored the entire publisher again!!! This person also
only cared about updating the browser stuff and not XMLRPC and VFS.
Furthermore, Browser-specific stuff reoccirred in generic directories where
they do not belong. I also found much unused code, like the entire
AttributePublisher, which seems deprecated! I did not fix the latter two
problems, since it already took me 9 hours to get the basic XMLRPC running
in the new design. (If you can tell, I am a little aggrevated about this,
since we had it clean before and I wasted a lot of time on it last night!)
So, I would therefore propose a MAJOR Publisher/Publication code cleanup
where we throw out the unused stuff and put code to the place where it
belongs.
I have not even checked the VFS implementation yet to see how bad the
damage is there...
But afterall, at least XMLRPC works again, and I think I will be able to
fix VFS too.
=== Added File Zope3/lib/python/Zope/Publisher/XMLRPC/IXMLRPCPresentation.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: IXMLRPCPresentation.py,v 1.1 2002/06/16 18:40:24 srichter Exp $
"""
from Zope.ComponentArchitecture.IPresentation import IPresentation
class IXMLRPCPresentation(IPresentation):
"""XMLRPC presentations are for interaction with user's
"""
=== Added File Zope3/lib/python/Zope/Publisher/XMLRPC/IXMLRPCPublication.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: IXMLRPCPublication.py,v 1.1 2002/06/16 18:40:24 srichter Exp $
"""
from Zope.Publisher.IPublication import IPublication
class IXMLRPCPublication (IPublication):
"""Object publication framework."""
def getDefaultTraversal(request, ob):
"""Get the default published object for the request
Allows a default view to be added to traversal.
Returns (ob, steps_reversed).
"""
=== Added File Zope3/lib/python/Zope/Publisher/XMLRPC/IXMLRPCView.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: IXMLRPCView.py,v 1.1 2002/06/16 18:40:24 srichter Exp $
"""
from Zope.ComponentArchitecture.IView import IView
from IXMLRPCPresentation import IXMLRPCPresentation
class IXMLRPCView(IXMLRPCPresentation, IView):
"XMLRPC View"
=== Added File Zope3/lib/python/Zope/Publisher/XMLRPC/XMLRPCView.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: XMLRPCView.py,v 1.1 2002/06/16 18:40:24 srichter Exp $
"""
__metaclass__ = type # All classes are new style when run with Python 2.2+
from IXMLRPCView import IXMLRPCView
class XMLRPCView:
__implements__ = IXMLRPCView
def __init__(self, context, request):
self.context = context
self.request = request
=== Zope3/lib/python/Zope/Publisher/XMLRPC/IXMLRPCPublisher.py 1.2 => 1.3 ===
$Id$
"""
-from Zope.Publisher.HTTP.IHTTPPublisher import IHTTPPublisher
-
-
-class IXMLRPCPublisher(IHTTPPublisher):
- """This is identical to the regular HTTP version.
-
- This interface is used as marker.
- """
+from Zope.Publisher.IPublishTraverse import IPublishTraverse
+class IXMLRPCPublisher(IPublishTraverse):
+ """XML-RPC Publisher"""
=== Zope3/lib/python/Zope/Publisher/XMLRPC/XMLRPCRequest.py 1.2 => 1.3 ===
from Zope.Publisher.HTTP.HTTPRequest import HTTPRequest
from IXMLRPCPublisher import IXMLRPCPublisher
+from IXMLRPCPublication import IXMLRPCPublication
+from IXMLRPCPresentation import IXMLRPCPresentation
from XMLRPCResponse import XMLRPCResponse
class XMLRPCRequest(HTTPRequest):
- __implements__ = HTTPRequest.__implements__
+ __implements__ = HTTPRequest.__implements__, IXMLRPCPublication
# _presentation_type is overridden from the BaseRequest
# to implement IXMLRPCPublisher
- _presentation_type = IXMLRPCPublisher
+ _presentation_type = IXMLRPCPresentation
_args = ()
@@ -40,7 +42,7 @@
return XMLRPCResponse(outstream)
- ######################################
+ ###################################################################
# from: Zope.Publisher.IPublisherRequest.IPublisherRequest
def processInputs(self):
@@ -54,6 +56,8 @@
if function:
self.setPathSuffix((function,))
+ #
+ ###################################################################
class TestRequest(XMLRPCRequest):
=== Zope3/lib/python/Zope/Publisher/XMLRPC/XMLRPCResponse.py 1.2 => 1.3 ===
$Id$
"""
-
-import sys
import xmlrpclib
+
from Zope.Publisher.HTTP.HTTPResponse import HTTPResponse
-from Zope.Publisher.Exceptions import Redirect
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
class XMLRPCResponse(HTTPResponse):
"""XMLRPC response
"""
+ __implements__ = HTTPResponse.__implements__
+
+
def setBody(self, body):
"""Sets the body of the response
@@ -38,6 +40,7 @@
If is_error is true then the HTML will be formatted as a Zope error
message instead of a generic HTML page.
"""
+ body = removeAllProxies(body)
if isinstance(body, xmlrpclib.Fault):
# Convert Fault object to XML-RPC response.
body = xmlrpclib.dumps(body, methodresponse=1)
@@ -49,8 +52,8 @@
body = xmlrpclib.False # Argh, XML-RPC doesn't handle null
try:
body = xmlrpclib.dumps((body,), methodresponse=1)
- except:
- self.exception()
+ except Exception, e:
+ self.handleException(e)
return
# Set our body to the XML-RPC message, and fix our MIME type.
self.setHeader('content-type', 'text/xml')
@@ -58,10 +61,12 @@
self._body = body
self._updateContentLength()
+ if not self._status_set:
+ self.setStatus(200)
+
def handleException(self, exc_info):
- """
- """
+ """Handle Errors during publsihing and wrap it in XML-RPC XML"""
t, value = exc_info[:2]
import traceback