[Zope3-checkins] CVS: Zope3/src/zope/publisher - base.py:1.9 browser.py:1.20 http.py:1.26

Albertas Agejevas alga@codeworks.lt
Mon, 9 Jun 2003 12:39:45 -0400


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

Modified Files:
	base.py browser.py http.py 
Log Message:
Make authenticated principal name appear in the hit logs.

This forced us to do some marginal hockery that is best removed when the 
HTTP server machinery is refactored.  More info in the comments.


=== Zope3/src/zope/publisher/base.py 1.8 => 1.9 ===
--- Zope3/src/zope/publisher/base.py:1.8	Tue Jun  3 10:32:06 2003
+++ Zope3/src/zope/publisher/base.py	Mon Jun  9 12:39:14 2003
@@ -28,6 +28,7 @@
 from zope.publisher.interfaces import NotFound, DebugError, Unauthorized
 from zope.publisher.interfaces import IRequest, IResponse
 from zope.publisher.publish import mapply
+from zope.server.interfaces import IHeaderOutput
 
 _marker = object()
 
@@ -177,7 +178,7 @@
         '_body',             # The request body as a string
         '_publication',      # publication object
         '_presentation_skin', # View skin
-        'user'               # request user, set by publication
+        '_user'               # request user, set by publication
         )
 
     environment = RequestDataProperty(RequestEnvironment)
@@ -196,7 +197,12 @@
             self._response = response
         self._body_instream = body_instream
         self._held = ()
-        self.user = None
+        self._user = None
+
+    def setUser(self, user):
+        self._user = user
+
+    user = property(lambda self: self._user)
 
     def _getPublication(self):
         'See IPublisherRequest'


=== Zope3/src/zope/publisher/browser.py 1.19 => 1.20 ===
--- Zope3/src/zope/publisher/browser.py:1.19	Tue Jun  3 10:32:06 2003
+++ Zope3/src/zope/publisher/browser.py	Mon Jun  9 12:39:14 2003
@@ -30,6 +30,7 @@
 from zope.publisher.interfaces.browser import IBrowserView
 from zope.component import getAdapter
 from zope.publisher.http import HTTPRequest, HTTPResponse
+from zope.publisher.base import BaseRequest
 
 __metaclass__ = type # All classes are new style when run with Python 2.2+
 
@@ -734,6 +735,11 @@
         super(TestRequest, self).__init__(body_instream, outstream, _testEnv)
         if form:
             self.form.update(form)
+
+    def setUser(self, user):
+        # HTTPRequest needs to notify the HTTPTask of the username.
+        # We don't want to have to stub HTTPTask in the tests.
+        BaseRequest.setUser(self, user)
 
 class BrowserResponse(HTTPResponse):
     """Browser response


=== Zope3/src/zope/publisher/http.py 1.25 => 1.26 ===
--- Zope3/src/zope/publisher/http.py:1.25	Tue Jun  3 10:32:06 2003
+++ Zope3/src/zope/publisher/http.py	Mon Jun  9 12:39:14 2003
@@ -506,6 +506,22 @@
         self._response.setHeader("WWW-Authenticate", challenge, True)
         self._response.setStatus(401)
 
+    def setUser(self, user):
+        'See IPublicationRequest'
+        super(HTTPRequest, self).setUser(user)
+
+        # XXX: under the publishing conditions,
+        # self.response._outstream 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.
+        #
+        # 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())
+
     #
     ############################################################