[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/HTTP - BrowserPayload.py:1.1.2.9
Shane Hathaway
shane@digicool.com
Mon, 7 Jan 2002 10:43:07 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/HTTP
In directory cvs.zope.org:/tmp/cvs-serv807
Modified Files:
Tag: Zope-3x-branch
BrowserPayload.py
Log Message:
- Fixed missing name, hide_key
- Removed dead code
- Put setStatus() back the way it should be.
=== Zope3/lib/python/Zope/Publisher/HTTP/BrowserPayload.py 1.1.2.8 => 1.1.2.9 ===
from types import ClassType, ListType, StringType
from cgi import FieldStorage, escape
-from cgi_names import isCGI_NAME
+from cgi_names import isCGI_NAME, hide_key
from IPayload import IRequestPayload, IResponsePayload
from Zope.Publisher.Converters import get_converter
from Zope.Publisher.Exceptions import Redirect, Unauthorized
-#from Zope.Publisher.Browser import IBrowserPublish
-
latin1_alias_match = re.compile(
r'text/html(\s*;\s*charset=((latin)|(latin[-_]?1)|'
@@ -39,10 +37,6 @@
def __init__(self, publication):
self.publication = publication
- def getPreferredPublishingType(self):
- #return IBrowserPublish
- return None
-
def processInputs(
self, request, fs=None,
# "static" variables that we want to be local for speed
@@ -471,7 +465,6 @@
s[:14].lower() == '<!doctype html')
def insertBase(self, response, body):
-
# Only insert a base tag if content appears to be html.
content_type = response.headers.get('content-type', '').split(';')[0]
if content_type and content_type != 'text/html':
@@ -500,7 +493,7 @@
def handleException(self, response, exc_info):
"""
- Calls setBody() with an error response.
+ Calls response.setBody() with an error response.
"""
t, v = exc_info[:2]
if isinstance(t, ClassType):
@@ -511,8 +504,10 @@
else:
title = tname = str(t)
- # XXX how should apps control the HTTP status code?
- ##response.setStatus(tname)
+ # Throwing non-protocol-specific exceptions is a good way
+ # for apps to control the status code.
+ response.setStatus(tname)
+
tb = escape(traceback_string(t, v, exc_info[2]))
body = self._html(title, "<pre>\n%s\n</pre>" % tb)
response.setBody(body)