[Checkins] SVN: zope.app.wsgi/branches/achapman_username_logging/src/zope/app/wsgi/__init__.py refactoring of logging user names

Alex Chapman achapman at zope.com
Wed Apr 1 09:59:21 EDT 2009


Log message for revision 98750:
  refactoring of logging user names

Changed:
  U   zope.app.wsgi/branches/achapman_username_logging/src/zope/app/wsgi/__init__.py

-=-
Modified: zope.app.wsgi/branches/achapman_username_logging/src/zope/app/wsgi/__init__.py
===================================================================
--- zope.app.wsgi/branches/achapman_username_logging/src/zope/app/wsgi/__init__.py	2009-04-01 13:56:57 UTC (rev 98749)
+++ zope.app.wsgi/branches/achapman_username_logging/src/zope/app/wsgi/__init__.py	2009-04-01 13:59:21 UTC (rev 98750)
@@ -23,6 +23,7 @@
 from zope.event import notify
 from zope.interface import implements
 from zope.publisher.publish import publish
+from zope.publisher.interfaces.logginginfo import ILoggingInfo
 
 from zope.app.appsetup import appsetup
 from zope.app.publication.httpfactory import HTTPPublicationRequestFactory
@@ -55,11 +56,13 @@
 
         request = publish(request, handle_errors=handle_errors)
         response = request.response
-        try:
-            environ['wsgi.user_name'] = format_login(
-                request.principal.info.login) 
-        except AttributeError:
-            pass
+        # Get logging info from principal for log use
+        logging_info = ILoggingInfo(request.principal, None)
+        if logging_info is None:
+            message = '-'
+        else:
+            message = logging_info.getLogMessage()
+        environ['wsgi.logging_info'] = message
 
         # Start the WSGI server response
         start_response(response.getStatusString(), response.getHeaders())
@@ -68,13 +71,6 @@
         return response.consumeBodyIter()
 
 
-# Defensive against ids with whitespace
-def format_login(login):
-    if login != login.replace(' ',''):
-        login = '"'+login+'"'
-    return login
-
-
 class PMDBWSGIPublisherApplication(WSGIPublisherApplication):
 
     def __init__(self, db=None, factory=HTTPPublicationRequestFactory,



More information about the Checkins mailing list