[Checkins] SVN: zope.app.wsgi/tags/3.9.3zc1/ Backport REMOTE_USER feature from trunk, because the trunck is too hard to swallow :(

Jim Fulton jim at zope.com
Sat Jan 14 18:07:29 UTC 2012


Log message for revision 124044:
  Backport REMOTE_USER feature from trunk, because the trunck is too hard to swallow :(

Changed:
  U   zope.app.wsgi/tags/3.9.3zc1/CHANGES.txt
  U   zope.app.wsgi/tags/3.9.3zc1/src/zope/app/wsgi/README.txt
  U   zope.app.wsgi/tags/3.9.3zc1/src/zope/app/wsgi/__init__.py

-=-
Modified: zope.app.wsgi/tags/3.9.3zc1/CHANGES.txt
===================================================================
--- zope.app.wsgi/tags/3.9.3zc1/CHANGES.txt	2012-01-14 18:04:09 UTC (rev 124043)
+++ zope.app.wsgi/tags/3.9.3zc1/CHANGES.txt	2012-01-14 18:07:28 UTC (rev 124044)
@@ -3,6 +3,18 @@
 =======
 
 
+3.9.3zc1 (2012-01-14)
+---------------------
+
+- Set the WSGI environment's ``REMOTE_USER`` item (if not already set)
+  with the Zope principal label. (This is the same data set in
+  the ``wsgi.logging_info`` environment item.)
+
+  This change allows user info to be used by `paste.translogger
+  <http://pythonpaste.org/modules/translogger.html>`_ middleware (or
+  any similar middleware that uses ``REMOTE_USER``), which provides
+  access logging.
+
 3.9.3 (2010-10-14)
 ------------------
 

Modified: zope.app.wsgi/tags/3.9.3zc1/src/zope/app/wsgi/README.txt
===================================================================
--- zope.app.wsgi/tags/3.9.3zc1/src/zope/app/wsgi/README.txt	2012-01-14 18:04:09 UTC (rev 124043)
+++ zope.app.wsgi/tags/3.9.3zc1/src/zope/app/wsgi/README.txt	2012-01-14 18:07:28 UTC (rev 124044)
@@ -104,11 +104,30 @@
 `ILoggingInfo`. Out-of-the-box, `zope.publisher` registers a base
 adapter that returns the principal id as value::
 
-  >>> print environ
-  {'wsgi.input': <cStringIO.StringI object at ...>,
-   'wsgi.logging_info': 'zope.anybody', 'PATH_INFO': '/'}
+  >>> from pprint import pprint
+  >>> pprint(environ)
+  {'PATH_INFO': '/',
+   'REMOTE_USER': 'zope.anybody',
+   'wsgi.input': <cStringIO.StringI object at ...>,
+   'wsgi.logging_info': 'zope.anybody'}
 
+.. edge case
 
+   If remote user is already set, don't update it:
+
+    >>> environ = {
+    ...     'PATH_INFO': '/',
+    ...     'REMOTE_USER': 'someoneelse',
+    ...     'wsgi.input': cStringIO.StringIO('')}
+
+    >>> _ = list(app(environ, start_response))
+    >>> pprint(environ)
+    {'PATH_INFO': '/',
+     'REMOTE_USER': 'someoneelse',
+     'wsgi.input': <cStringIO.StringI object at ...>,
+     'wsgi.logging_info': 'zope.anybody'}
+
+
 Creating A WSGI Application
 ---------------------------
 

Modified: zope.app.wsgi/tags/3.9.3zc1/src/zope/app/wsgi/__init__.py
===================================================================
--- zope.app.wsgi/tags/3.9.3zc1/src/zope/app/wsgi/__init__.py	2012-01-14 18:04:09 UTC (rev 124043)
+++ zope.app.wsgi/tags/3.9.3zc1/src/zope/app/wsgi/__init__.py	2012-01-14 18:07:28 UTC (rev 124044)
@@ -65,6 +65,8 @@
         else:
             message = logging_info.getLogMessage()
         environ['wsgi.logging_info'] = message
+        if 'REMOTE_USER' not in environ:
+            environ['REMOTE_USER'] = message
 
         # Start the WSGI server response
         start_response(response.getStatusString(), response.getHeaders())



More information about the checkins mailing list