Commit d5d72e9a authored by Hanno Schlichting's avatar Hanno Schlichting

Cleanup and make base request/response new-style classes.

parent debe7079
...@@ -179,7 +179,7 @@ class DefaultPublishTraverse(object): ...@@ -179,7 +179,7 @@ class DefaultPublishTraverse(object):
return self.context, () return self.context, ()
class BaseRequest: class BaseRequest(object):
"""Provide basic ZPublisher request management """Provide basic ZPublisher request management
This object provides access to request data. Request data may This object provides access to request data. Request data may
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
from zExceptions import Unauthorized, Forbidden, NotFound, BadRequest from zExceptions import Unauthorized, Forbidden, NotFound, BadRequest
class BaseResponse: class BaseResponse(object):
"""Base Response Class """Base Response Class
""" """
debug_mode = None debug_mode = None
...@@ -59,7 +59,7 @@ class BaseResponse: ...@@ -59,7 +59,7 @@ class BaseResponse:
return self.status return self.status
def setCookie(self, name, value, **kw): def setCookie(self, name, value, **kw):
'''\ '''
Set an HTTP cookie on the browser Set an HTTP cookie on the browser
The response will include an HTTP header that sets a cookie on The response will include an HTTP header that sets a cookie on
...@@ -80,12 +80,13 @@ class BaseResponse: ...@@ -80,12 +80,13 @@ class BaseResponse:
self.setBody(self.getBody() + body) self.setBody(self.getBody() + body)
def getHeader(self, name): def getHeader(self, name):
'''\ '''
Get a header value Get a header value
Returns the value associated with a HTTP return header, or Returns the value associated with a HTTP return header, or
"None" if no such header has been set in the response "None" if no such header has been set in the response
yet. ''' yet.
'''
return self.headers.get(name, None) return self.headers.get(name, None)
def __getitem__(self, name): def __getitem__(self, name):
...@@ -106,7 +107,7 @@ class BaseResponse: ...@@ -106,7 +107,7 @@ class BaseResponse:
pass pass
def write(self, data): def write(self, data):
"""\ """
Return data as a stream Return data as a stream
HTML data may be returned using a stream-oriented interface. HTML data may be returned using a stream-oriented interface.
...@@ -118,7 +119,6 @@ class BaseResponse: ...@@ -118,7 +119,6 @@ class BaseResponse:
Note that published objects must not generate any errors Note that published objects must not generate any errors
after beginning stream-oriented output. after beginning stream-oriented output.
""" """
self.body = self.body + data self.body = self.body + data
...@@ -137,7 +137,7 @@ class BaseResponse: ...@@ -137,7 +137,7 @@ class BaseResponse:
raise NotFound(v) raise NotFound(v)
def debugError(self, v=''): def debugError(self, v=''):
"""Raise an error with debigging info and in debugging mode""" """Raise an error with debugging info and in debugging mode"""
raise NotFound("Debugging notice: %s" % v) raise NotFound("Debugging notice: %s" % v)
def badRequestError(self, v=''): def badRequestError(self, v=''):
...@@ -149,7 +149,7 @@ class BaseResponse: ...@@ -149,7 +149,7 @@ class BaseResponse:
raise Forbidden(v) raise Forbidden(v)
def unauthorized(self): def unauthorized(self):
"""Raise an eror indicating that the user was not authizated """Raise an error indicating that the user was not authorized.
Make sure to generate an appropriate challenge, as appropriate. Make sure to generate an appropriate challenge, as appropriate.
""" """
......
...@@ -97,7 +97,7 @@ class HTTPResponse(BaseResponse): ...@@ -97,7 +97,7 @@ class HTTPResponse(BaseResponse):
The Response type encapsulates all possible responses to HTTP The Response type encapsulates all possible responses to HTTP
requests. Responses are normally created by the object publisher. requests. Responses are normally created by the object publisher.
A published object may recieve the response abject as an argument A published object may receive the response abject as an argument
named 'RESPONSE'. A published object may also create it's own named 'RESPONSE'. A published object may also create it's own
response object. Normally, published objects use response objects response object. Normally, published objects use response objects
to: to:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment