[Zope3-checkins] CVS: Zope3/src/zope/testing - functional.py:1.9

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


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

Modified Files:
	functional.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/testing/functional.py 1.8 => 1.9 ===
--- Zope3/src/zope/testing/functional.py:1.8	Thu May 22 09:58:55 2003
+++ Zope3/src/zope/testing/functional.py	Mon Jun  9 12:39:16 2003
@@ -23,7 +23,7 @@
 import traceback
 import unittest
 
-from cStringIO import StringIO
+from StringIO import StringIO
 
 from transaction import get_transaction
 from zodb.db import DB
@@ -37,6 +37,14 @@
 from zope.publisher.publish import publish
 from zope.exceptions import Forbidden, Unauthorized
 
+__metaclass__ = type
+
+
+class HTTPTaskStub(StringIO):
+
+    def setAuthUserName(self, user):
+        pass
+
 
 class ResponseWrapper:
     """A wrapper that adds several introspective methods to a response."""
@@ -161,7 +169,7 @@
           outstream -- a stream where the HTTP response will be written
         """
         if outstream is None:
-            outstream = StringIO()
+            outstream = HTTPTaskStub()
         environment = {"HTTP_HOST": 'localhost',
                        "HTTP_REFERER": 'localhost'}
         environment.update(env)
@@ -186,7 +194,7 @@
           getBody()      -- returns the full response body as a string
           getPath()      -- returns the path used in the request
         """
-        outstream = StringIO()
+        outstream = HTTPTaskStub()
         request = self.makeRequest(path, basic=basic, form=form, env=env,
                                    outstream=outstream)
         response = ResponseWrapper(request.response, outstream, path)
@@ -272,7 +280,7 @@
           outstream -- a stream where the HTTP response will be written
         """
         if outstream is None:
-            outstream = StringIO()
+            outstream = HTTPTaskStub()
         if instream is None:
             instream = ''
         environment = {"HTTP_HOST": 'localhost',
@@ -299,7 +307,7 @@
           getBody()      -- returns the full response body as a string
           getPath()      -- returns the path used in the request
         """
-        outstream = StringIO()
+        outstream = HTTPTaskStub()
         request = self.makeRequest(path, basic=basic, form=form, env=env,
                                    instream=request_body, outstream=outstream)
         response = ResponseWrapper(request.response, outstream, path)