[Zope3-checkins]
SVN: Zope3/branches/srichter-twisted-integration/src/zope/publisher/
Fixed madness!!! Someone made requets/response objects know
about HTTP
Stephan Richter
srichter at cosmos.phy.tufts.edu
Mon Apr 18 16:04:51 EDT 2005
Log message for revision 30027:
Fixed madness!!! Someone made requets/response objects know about HTTP
tasks. But HTTP tasks are ZServer-specific and a dependence to zope.server
was created.
I know why this was done; the person wanted to display the username in the
access log. But it was just the wrong thing to do. After much thinking
with Itamar this weekend, the app server will be responsible for the log
message.
Changed:
U Zope3/branches/srichter-twisted-integration/src/zope/publisher/http.py
U Zope3/branches/srichter-twisted-integration/src/zope/publisher/interfaces/http.py
U Zope3/branches/srichter-twisted-integration/src/zope/publisher/tests/test_http.py
-=-
Modified: Zope3/branches/srichter-twisted-integration/src/zope/publisher/http.py
===================================================================
--- Zope3/branches/srichter-twisted-integration/src/zope/publisher/http.py 2005-04-18 19:54:49 UTC (rev 30026)
+++ Zope3/branches/srichter-twisted-integration/src/zope/publisher/http.py 2005-04-18 20:04:51 UTC (rev 30027)
@@ -464,15 +464,6 @@
self._response.setHeader("WWW-Authenticate", challenge, True)
self._response.setStatus(401)
- def setPrincipal(self, principal):
- 'See IPublicationRequest'
- super(HTTPRequest, self).setPrincipal(principal)
-
- if self.response.http_transaction is not None:
- logging_info = ILoggingInfo(principal)
- message = logging_info.getLogMessage()
- self.response.http_transaction.setAuthUserName(message)
-
def _createResponse(self, outstream):
# Should be overridden by subclasses
return HTTPResponse(outstream)
@@ -582,13 +573,11 @@
'_reason', # The reason that goes with the status
'_status_set', # Boolean: status explicitly set
'_charset', # String: character set for the output
- 'http_transaction', # HTTPTask object
)
- def __init__(self, outstream, header_output=None, http_transaction=None):
+ def __init__(self, outstream, header_output=None):
self._header_output = header_output
- self.http_transaction = http_transaction
super(HTTPResponse, self).__init__(outstream)
self.reset()
@@ -608,9 +597,6 @@
def setHeaderOutput(self, header_output):
self._header_output = header_output
- def setHTTPTransaction(self, http_transaction):
- self.http_transaction = http_transaction
-
def setStatus(self, status, reason=None):
'See IHTTPResponse'
if status is None:
Modified: Zope3/branches/srichter-twisted-integration/src/zope/publisher/interfaces/http.py
===================================================================
--- Zope3/branches/srichter-twisted-integration/src/zope/publisher/interfaces/http.py 2005-04-18 19:54:49 UTC (rev 30026)
+++ Zope3/branches/srichter-twisted-integration/src/zope/publisher/interfaces/http.py 2005-04-18 20:04:51 UTC (rev 30027)
@@ -383,9 +383,3 @@
"""This convinience function determines the character set based on the
HTTP header information.
"""
-
- def setHTTPTransaction(http_transaction):
- """Sets an HTTP transaction.
-
- Returns an HTTPTask or None. It is used for logging.
- """
Modified: Zope3/branches/srichter-twisted-integration/src/zope/publisher/tests/test_http.py
===================================================================
--- Zope3/branches/srichter-twisted-integration/src/zope/publisher/tests/test_http.py 2005-04-18 19:54:49 UTC (rev 30026)
+++ Zope3/branches/srichter-twisted-integration/src/zope/publisher/tests/test_http.py 2005-04-18 20:04:51 UTC (rev 30027)
@@ -325,21 +325,6 @@
lpw = req._authUserPW()
self.assertEquals(lpw, (login, password))
- def testSetPrincipal(self):
- class HTTPTaskStub(object):
- auth_user_name = None
- def setAuthUserName(self, name):
- self.auth_user_name = name
-
- task = HTTPTaskStub()
- req = self._createRequest(outstream=task)
- req.setPrincipal(UserStub("jim"))
- self.assert_(not req.response._outstream.auth_user_name)
- req = self._createRequest(outstream=task)
- req.response.setHTTPTransaction(task)
- req.setPrincipal(UserStub("jim"))
- self.assertEquals(req.response.http_transaction.auth_user_name, "jim")
-
def test_method(self):
r = self._createRequest(extra_env={'REQUEST_METHOD':'SPAM'})
self.assertEqual(r.method, 'SPAM')
More information about the Zope3-Checkins
mailing list