[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/pas/httpplugins.py Whitespace, typos, style.

Florent Guillaume fg at nuxeo.com
Mon Oct 11 06:35:31 EDT 2004


Log message for revision 27955:
  Whitespace, typos, style.
  Add a bit to the docstrings.
  


Changed:
  U   Zope3/trunk/src/zope/app/pas/httpplugins.py


-=-
Modified: Zope3/trunk/src/zope/app/pas/httpplugins.py
===================================================================
--- Zope3/trunk/src/zope/app/pas/httpplugins.py	2004-10-11 10:28:21 UTC (rev 27954)
+++ Zope3/trunk/src/zope/app/pas/httpplugins.py	2004-10-11 10:35:31 UTC (rev 27955)
@@ -29,7 +29,7 @@
     """A Basic HTTP Authentication Crendentials Extraction Plugin
 
     First we need to create a request that contains some credentials.
-    
+
     >>> from zope.publisher.browser import TestRequest
     >>> request = TestRequest(
     ...     environ={'HTTP_AUTHORIZATION': u'Basic bWdyOm1ncnB3'})
@@ -46,7 +46,7 @@
     >>> extractor.extractCredentials(TestRequest()) is None
     True
 
-    Also, this extractor can *only* hadle basic authentication.
+    Also, this extractor can *only* handle basic authentication.
 
     >>> request = TestRequest({'HTTP_AUTHORIZATION': 'foo bar'})
     >>> extractor.extractCredentials(TestRequest()) is None
@@ -57,10 +57,11 @@
     def extractCredentials(self, request):
         if request._auth:
             if request._auth.lower().startswith(u'basic '):
-                credentials = request._auth.split()[-1] 
-                username, password = base64.decodestring(credentials).split(':')
-                return {'login': username.decode('utf-8'),
+                credentials = request._auth.split()[-1]
+                login, password = base64.decodestring(credentials).split(':')
+                return {'login': login.decode('utf-8'),
                         'password': password.decode('utf-8')}
+        return None
 
 
 class HTTPBasicAuthChallenger(Persistent, Contained):
@@ -68,6 +69,8 @@
 
     >>> challenger = HTTPBasicAuthChallenger()
 
+    The challenger adds its challenge to the HTTP response.
+
     >>> from zope.publisher.browser import TestRequest
     >>> request = TestRequest()
     >>> response = request.response
@@ -78,6 +81,8 @@
     >>> response.getHeader('WWW-Authenticate', literal=True)
     'basic realm=Zope3'
 
+    The challenger only works with HTTP requests.
+
     >>> from zope.publisher.base import TestRequest
     >>> request = TestRequest('/')
     >>> response = request.response
@@ -87,13 +92,12 @@
     implements(IChallengePlugin)
 
     realm = 'Zope3'
+    protocol = 'http auth'
 
-    protocol = 'http auth'
-    
     def challenge(self, request, response):
         if not IHTTPRequest.providedBy(request):
             return None
-        response.setHeader("WWW-Authenticate", "basic realm=%s" %self.realm,
-                           True)
+        response.setHeader("WWW-Authenticate", "basic realm=%s" % self.realm,
+                           literal=True)
         response.setStatus(401)
         return True



More information about the Zope3-Checkins mailing list