[Zope3-checkins] CVS: Zope3/src/zope/publisher - http.py:1.11
Steve Alexander
steve@cat-box.net
Fri, 28 Feb 2003 09:21:57 -0500
Update of /cvs-repository/Zope3/src/zope/publisher
In directory cvs.zope.org:/tmp/cvs-serv31752/src/zope/publisher
Modified Files:
http.py
Log Message:
Cleaned up some formatting.
Changed some uses of 1 and 0 as boolean values into True and False.
=== Zope3/src/zope/publisher/http.py 1.10 => 1.11 ===
--- Zope3/src/zope/publisher/http.py:1.10 Thu Feb 27 03:11:33 2003
+++ Zope3/src/zope/publisher/http.py Fri Feb 28 09:21:26 2003
@@ -214,7 +214,7 @@
raise
DEFAULT_PORTS = {'http': '80', 'https': '443'}
-STAGGER_RETRIES = 1
+STAGGER_RETRIES = True
class HTTPRequest(BaseRequest):
"""
@@ -420,7 +420,7 @@
if count < self.retry_max_count:
if STAGGER_RETRIES:
time.sleep(random.uniform(0, 2**(count)))
- return 1
+ return True
def retry(self):
@@ -507,7 +507,7 @@
def unauthorized(self, challenge):
'See IHTTPCredentials'
- self._response.setHeader("WWW-Authenticate", challenge, 1)
+ self._response.setHeader("WWW-Authenticate", challenge, True)
self._response.setStatus(401)
#
@@ -518,7 +518,7 @@
return HTTPResponse(outstream)
- def getURL(self, level=0, path_only=0):
+ def getURL(self, level=0, path_only=False):
names = self._app_names + self._traversed_names
if level:
if level > len(names):
@@ -533,7 +533,7 @@
if not names: return self._app_server
return "%s/%s" % (self._app_server, '/'.join(names))
- def getApplicationURL(self, depth=0, path_only=0):
+ def getApplicationURL(self, depth=0, path_only=False):
if depth:
names = self._traversed_names
if depth > len(names):
@@ -578,8 +578,8 @@
class HTTPResponse (BaseResponse):
- __implements__ = IHTTPResponse, IHTTPApplicationResponse, \
- BaseResponse.__implements__
+ __implements__ = (IHTTPResponse, IHTTPApplicationResponse,
+ BaseResponse.__implements__)
__slots__ = (
'_header_output', # Hook object to collaborate with a server
@@ -596,18 +596,18 @@
)
- def __init__(self, outstream, header_output = None):
+ def __init__(self, outstream, header_output=None):
self._header_output = header_output
super(HTTPResponse, self).__init__(outstream)
self._headers = {}
self._cookies = {}
self._accumulated_headers = []
- self._wrote_headers = 0
- self._streaming = 0
+ self._wrote_headers = False
+ self._streaming = False
self._status = 599
self._reason = 'No status set'
- self._status_set = 0
+ self._status_set = False
self._charset = None
@@ -635,7 +635,7 @@
else:
reason = 'Unknown'
self._reason = reason
- self._status_set = 1
+ self._status_set = True
def getStatus(self):
@@ -643,7 +643,7 @@
return self._status
- def setHeader(self, name, value, literal=0):
+ def setHeader(self, name, value, literal=False):
'See IHTTPResponse'
name = str(name)
@@ -755,7 +755,7 @@
if envadaptor is None:
return
- # XXX This try/except lools rather suspicious :(
+ # XXX This try/except looks rather suspicious :(
try:
charset = envadaptor.getPreferredCharsets()[0]
except:
@@ -784,7 +784,7 @@
# for apps to control the status code.
self.setStatus(tname)
- tb = ''.join(format_exception(t, v, exc_info[2], as_html=1))
+ tb = ''.join(format_exception(t, v, exc_info[2], as_html=True))
body = self._html(title, "%s" % tb)
self.setBody(body)
@@ -900,11 +900,10 @@
def output(self, data):
if not self._wrote_headers:
self.outputHeaders()
- self._wrote_headers = 1
+ self._wrote_headers = True
- if self.getHeader('content-type', '').startswith('text') and \
- self._charset is not None and \
- type(data) is UnicodeType:
+ if (self.getHeader('content-type', '').startswith('text') and
+ self._charset is not None and type(data) is UnicodeType):
data = data.encode(self._charset)
self._outstream.write(data)