On Fri, Jan 17, 2003 at 01:47:24PM -0500, Graham Fawcett wrote:
>This patch catches all exceptions from the Publisher, and wraps
>non-PublishError exceptions in a medusa_http.ServerError instance.
Thanks for pointing out the problem, However, I think medusa_http.py
needs to match the logic of Publisher.publish(), which calls
finish_interrupted_request() if PublishError is raised and
finish_failed_request() if some other exception is raised. This
simplifies the patch because there's no need to synthesize a
ServerError exception to call finish_failed_request().
The patch below also makes some more changes to call the publisher's
.create_request() and .parse_request() methods, so file uploads should
now work with the Medusa server, though I haven't tested this.
Does the patch below work for you? If yes, then I'll check it in.
--amk
Index: medusa_http.py
===================================================================
--- medusa_http.py (revision 20290)
+++ medusa_http.py (working copy)
@@ -14,6 +14,7 @@
from medusa import http_server, xmlrpc_handler
from quixote.http_request import HTTPRequest
from quixote.publish import Publisher
+from quixote.errors import PublishError
class QuixoteHandler:
def __init__ (self, publisher, server_name, server):
@@ -69,9 +70,15 @@
environ[k] = ''
stdin = StringIO(data)
- qreq = HTTPRequest(stdin, environ)
- qreq.process_inputs()
- output = self.publisher.process_request(qreq, environ)
+ qreq = self.publisher.create_request(stdin, environ)
+ try:
+ self.publisher.parse_request(qreq)
+ output = self.publisher.process_request(qreq, environ)
+ except PublishError, err:
+ output = self.publisher.finish_interrupted_request(qreq, err)
+ except:
+ output = self.publisher.finish_failed_request(qreq)
+
if output:
qreq.response.set_body(str(output))