[Zope3-checkins]
SVN: Zope3/branches/stephan_and_jim-response-refactor/src/zope/
All functional tests pass.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Fri Sep 2 16:22:51 EDT 2005
Log message for revision 38252:
All functional tests pass.
Changed:
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publisher/xmlrpc/README.txt
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/wsgi/__init__.py
U Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/xmlrpc.py
-=-
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publisher/xmlrpc/README.txt
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publisher/xmlrpc/README.txt 2005-09-02 20:22:26 UTC (rev 38251)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/publisher/xmlrpc/README.txt 2005-09-02 20:22:50 UTC (rev 38252)
@@ -19,11 +19,11 @@
>>> from zope.configuration import xmlconfig
>>> ignored = xmlconfig.string("""
- ... <configure
+ ... <configure
... xmlns="http://namespaces.zope.org/zope"
... xmlns:xmlrpc="http://namespaces.zope.org/xmlrpc"
... >
- ... <!-- We only need to do this include in this example,
+ ... <!-- We only need to do this include in this example,
... Normally the include has already been done for us. -->
... <include package="zope.app.publisher.xmlrpc" file="meta.zcml" />
...
@@ -43,7 +43,7 @@
... Authorization: Basic bWdyOm1ncnB3
... Content-Length: 73
... Content-Type: application/x-www-form-urlencoded
- ...
+ ...
... type_name=BrowserAdd__zope.app.folder.folder.Folder&new_value=f1""")
HTTP/1.1 303 See Other
...
@@ -53,7 +53,7 @@
... Authorization: Basic bWdyOm1ncnB3
... Content-Length: 73
... Content-Type: application/x-www-form-urlencoded
- ...
+ ...
... type_name=BrowserAdd__zope.app.folder.folder.Folder&new_value=f2""")
HTTP/1.1 303 See Other
...
@@ -65,7 +65,7 @@
... Authorization: Basic bWdyOm1ncnB3
... Content-Length: 102
... Content-Type: text/xml
- ...
+ ...
... <?xml version='1.0'?>
... <methodCall>
... <methodName>contents</methodName>
@@ -98,7 +98,7 @@
... POST / HTTP/1.0
... Content-Length: 102
... Content-Type: text/xml
- ...
+ ...
... <?xml version='1.0'?>
... <methodCall>
... <methodName>contents</methodName>
@@ -109,7 +109,7 @@
HTTP/1.0 401 Unauthorized
Content-Length: 126
Content-Type: text/xml;charset=utf-8
- Www-Authenticate: basic realm='Zope'
+ WWW-Authenticate: basic realm='Zope'
<BLANKLINE>
<?xml version='1.0'?>
<methodResponse>
@@ -141,7 +141,7 @@
The 'zope.app.publisher.xmlrpc' package provides a base class,
`MethodPublisher`, that provides the necessary traversal support. In
-particulat, it has an adapter that simply traverses to attributes.
+particulat, it has an adapter that simply traverses to attributes.
If an XML-RPC view isn't going to be public, then it also has to
implement 'zope.app.location.ILocation' so that security grants can be
@@ -162,11 +162,11 @@
as as a named view:
>>> ignored = xmlconfig.string("""
- ... <configure
+ ... <configure
... xmlns="http://namespaces.zope.org/zope"
... xmlns:xmlrpc="http://namespaces.zope.org/xmlrpc"
... >
- ... <!-- We only need to do this include in this example,
+ ... <!-- We only need to do this include in this example,
... Normally the include has already been done for us. -->
... <include package="zope.app.publisher.xmlrpc" file="meta.zcml" />
...
@@ -187,7 +187,7 @@
... Authorization: Basic bWdyOm1ncnB3
... Content-Length: 102
... Content-Type: text/xml
- ...
+ ...
... <?xml version='1.0'?>
... <methodCall>
... <methodName>contents</methodName>
@@ -218,7 +218,7 @@
... POST /listing/ HTTP/1.0
... Content-Length: 102
... Content-Type: text/xml
- ...
+ ...
... <?xml version='1.0'?>
... <methodCall>
... <methodName>contents</methodName>
@@ -229,7 +229,7 @@
HTTP/1.0 401 Unauthorized
Content-Length: 126
Content-Type: text/xml;charset=utf-8
- Www-Authenticate: basic realm='Zope'
+ WWW-Authenticate: basic realm='Zope'
<BLANKLINE>
<?xml version='1.0'?>
<methodResponse>
@@ -258,11 +258,11 @@
>>> from zope.configuration import xmlconfig
>>> ignored = xmlconfig.string("""
- ... <configure
+ ... <configure
... xmlns="http://namespaces.zope.org/zope"
... xmlns:xmlrpc="http://namespaces.zope.org/xmlrpc"
... >
- ... <!-- We only need to do this include in this example,
+ ... <!-- We only need to do this include in this example,
... Normally the include has already been done for us. -->
... <include package="zope.app.publisher.xmlrpc" file="meta.zcml" />
...
@@ -283,7 +283,7 @@
... Authorization: Basic bWdyOm1ncnB3
... Content-Length: 159
... Content-Type: text/xml
- ...
+ ...
... <?xml version='1.0'?>
... <methodCall>
... <methodName>add</methodName>
@@ -327,11 +327,11 @@
>>> from zope.configuration import xmlconfig
>>> ignored = xmlconfig.string("""
- ... <configure
+ ... <configure
... xmlns="http://namespaces.zope.org/zope"
... xmlns:xmlrpc="http://namespaces.zope.org/xmlrpc"
... >
- ... <!-- We only need to do this include in this example,
+ ... <!-- We only need to do this include in this example,
... Normally the include has already been done for us. -->
... <include package="zope.app.publisher.xmlrpc" file="meta.zcml" />
...
@@ -351,7 +351,7 @@
... Authorization: Basic bWdyOm1ncnB3
... Content-Length: 104
... Content-Type: text/xml
- ...
+ ...
... <?xml version='1.0'?>
... <methodCall>
... <methodName>your_fault</methodName>
@@ -386,7 +386,7 @@
Unfortunately, `xmlrpclib` does not support Python 2.3's new
`datetime.datetime` class (it should be made to, really). DateTime
values need to be encoded as `xmlrpclib.DateTime` instances:
-
+
>>> import xmlrpclib
>>> class DateTimeDemo:
@@ -401,11 +401,11 @@
>>> from zope.configuration import xmlconfig
>>> ignored = xmlconfig.string("""
- ... <configure
+ ... <configure
... xmlns="http://namespaces.zope.org/zope"
... xmlns:xmlrpc="http://namespaces.zope.org/xmlrpc"
... >
- ... <!-- We only need to do this include in this example,
+ ... <!-- We only need to do this include in this example,
... Normally the include has already been done for us. -->
... <include package="zope.app.publisher.xmlrpc" file="meta.zcml" />
...
@@ -425,7 +425,7 @@
... Authorization: Basic bWdyOm1ncnB3
... Content-Length: 100
... Content-Type: text/xml
- ...
+ ...
... <?xml version='1.0'?>
... <methodCall>
... <methodName>epoch</methodName>
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/wsgi/__init__.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/wsgi/__init__.py 2005-09-02 20:22:26 UTC (rev 38251)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/app/wsgi/__init__.py 2005-09-02 20:22:50 UTC (rev 38252)
@@ -63,7 +63,7 @@
accum = [tuple(line.split(':', 1))
for line in self._accumulatedHeaders]
-
+
response_headers.extend(accum)
return response_headers
Modified: Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/xmlrpc.py
===================================================================
--- Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/xmlrpc.py 2005-09-02 20:22:26 UTC (rev 38251)
+++ Zope3/branches/stephan_and_jim-response-refactor/src/zope/publisher/xmlrpc.py 2005-09-02 20:22:50 UTC (rev 38252)
@@ -25,7 +25,7 @@
from zope.publisher.interfaces.xmlrpc import IXMLRPCPublisher
from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest
-from zope.publisher.http import HTTPRequest, HTTPResponse
+from zope.publisher.http import HTTPRequest, HTTPResponse, DirectResult
from zope.security.proxy import isinstance
@@ -77,8 +77,8 @@
This object is responsible for converting all output to valid XML-RPC.
"""
- def setBody(self, body):
- """Sets the body of the response
+ def setResult(self, result):
+ """Sets the result of the response
Sets the return body equal to the (string) argument "body". Also
updates the "content-length" return header.
@@ -89,7 +89,7 @@
If is_error is true then the HTML will be formatted as a Zope error
message instead of a generic HTML page.
"""
- body = premarshal(body)
+ body = premarshal(result)
if isinstance(body, xmlrpclib.Fault):
# Convert Fault object to XML-RPC response.
body = xmlrpclib.dumps(body, methodresponse=True)
@@ -104,16 +104,14 @@
# We really want to catch all exceptions at this point!
self.handleException(sys.exc_info())
return
- # Set our body to the XML-RPC message, and fix our MIME type.
- self.setHeader('content-type', 'text/xml')
- self._body = body
- self._updateContentLength()
+ super(XMLRPCResponse, self).setResult(
+ DirectResult((body,),
+ [('content-type', 'text/xml;charset=utf-8'),
+ ('content-length', str(len(body)))])
+ )
- if not self._status_set:
- self.setStatus(200)
-
def handleException(self, exc_info):
"""Handle Errors during publsihing and wrap it in XML-RPC XML
More information about the Zope3-Checkins
mailing list