durusmail: quixote-users: PublishError's HTTP reponse
PublishError's HTTP reponse
2003-09-15
2003-09-15
2003-09-15
2003-09-15
PublishError's HTTP reponse
John Belmonte
2003-09-15
Hello,

I found that PublishError is useless in the case where I need my server
to return "405 Method Not Allowed", because the HTTP RFC says you must
include an Allow header in that case, and PublishError does not let you
control the HTTP reponse.

I'd like to see support added for this.  Following is a minimal and
backwards-compatible patch that lets you create a PublishError instance
with an custom HTTP response.

Regards,
-John Belmonte


--
http:// if   le.o  /
--- /usr/lib/python2.2/site-packages/quixote/publish.py 2003-04-28
11:05:01.000000000 -0400
+++ publish.py  2003-09-15 13:59:47.000000000 -0400
@@ -304,7 +304,7 @@

         # Throw away the existing response object and start a new one
         # for the error document we're going to create here.
-        request.response = HTTPResponse()
+        request.response = exc.http_response or HTTPResponse()

         # set response status code so every custom doesn't have to do it
         request.response.set_status(exc.status_code)
--- /usr/lib/python2.2/site-packages/quixote/errors.py  2003-03-05
13:40:42.000000000 -0500
+++ errors.py   2003-09-15 14:00:55.000000000 -0400
@@ -36,9 +36,10 @@
     title = "Publishing error"
     description = "no description"

-    def __init__ (self, public_msg=None, private_msg=None):
+    def __init__ (self, public_msg=None, private_msg=None, http_response=None):
         self.public_msg = public_msg
         self.private_msg = private_msg # cleared if SECURE_ERRORS is true
+        self.http_reponse = http_reponse

     def __str__ (self):
         return self.private_msg or self.public_msg or "???"
reply