[Zope3-checkins] CVS: Zope3/src/zope/publisher - http.py:1.28

Viktorija Zaksiene ryzaja@codeworks.lt
Tue, 22 Jul 2003 05:34:09 -0400


Update of /cvs-repository/Zope3/src/zope/publisher
In directory cvs.zope.org:/tmp/cvs-serv19565/src/zope/publisher

Modified Files:
	http.py 
Log Message:
Added http_transaction attribute to the HTTPResponse. It is used for the
logging instead of _outstream attribute because _outstream may not know
about the user.


=== Zope3/src/zope/publisher/http.py 1.27 => 1.28 ===
--- Zope3/src/zope/publisher/http.py:1.27	Mon Jun 30 15:32:20 2003
+++ Zope3/src/zope/publisher/http.py	Tue Jul 22 05:33:34 2003
@@ -511,7 +511,7 @@
         super(HTTPRequest, self).setUser(user)
 
         # XXX: under the publishing conditions,
-        # self.response._outstream is an HTTPTask.  It needs to know
+        # self.response.http_transaction is an HTTPTask.  It needs to know
         # the username for logging purposes.  It would make sense to
         # do this in the server, when the actual hit log entry is
         # written, but it would require a major refactoring.
@@ -519,8 +519,8 @@
         # When removing this wart after the server refactoring, grep
         # the source for setAuthUserName, we had to stub that in
         # several tests.
-
-        self.response._outstream.setAuthUserName(user.getId())
+        if self.response.http_transaction is not None:
+            self.response.http_transaction.setAuthUserName(user.getId())
 
     #
     ############################################################
@@ -604,7 +604,7 @@
         return d.keys()
 
 
-class HTTPResponse (BaseResponse):
+class HTTPResponse(BaseResponse):
 
     implements(IHTTPResponse, IHTTPApplicationResponse)
 
@@ -620,11 +620,13 @@
         '_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):
+    def __init__(self, outstream, header_output=None, http_transaction=None):
         self._header_output = header_output
+        self.http_transaction = http_transaction
 
         super(HTTPResponse, self).__init__(outstream)
         self.reset()
@@ -644,6 +646,9 @@
 
     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'