[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - BaseResponse.py:1.8.54.1 HTTPResponse.py:1.48.24.1

Jim Fulton jim@zope.com
Mon, 15 Oct 2001 17:22:45 -0400


Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv21338/lib/python/ZPublisher

Modified Files:
      Tag: cAccessControl-review-branch
	BaseResponse.py HTTPResponse.py 
Log Message:
Checking in changes made during review of new cAccessControl
implementation. The changes fall into two classes:

- Changes made to C code

- Switching to use of Unauthorized class exception.
  This one is especially significant. :)


=== Zope/lib/python/ZPublisher/BaseResponse.py 1.8 => 1.8.54.1 ===
 from string import find, rfind, lower, upper, strip, split, join, translate
 from types import StringType, InstanceType
+from zExceptions import Unauthorized
 
 class BaseResponse:
     """Base Response Class
@@ -226,4 +227,4 @@
 
         Make sure to generate an appropriate challenge, as appropriate.
         """
-        raise 'Unauthorized'
+        raise Unauthorized


=== Zope/lib/python/ZPublisher/HTTPResponse.py 1.48 => 1.48.24.1 ===
 from types import StringType, InstanceType, LongType
 from BaseResponse import BaseResponse
+from zExceptions import Unauthorized
 
 nl2sp=string.maketrans('\n',' ')
 
@@ -578,7 +579,7 @@
                 m=m+'<p>\nUsername and password are not correct.'
             else:
                 m=m+'<p>\nNo Authorization header found.'
-        raise 'Unauthorized', m
+        raise Unauthorized, m
 
     def exception(self, fatal=0, info=None,
                   absuri_match=re.compile(r'\w+://[\w\.]+').match,
@@ -588,7 +589,10 @@
         if type(info) is type(()) and len(info)==3: t,v,tb = info
         else: t,v,tb = sys.exc_info()
 
-        if str(t)=='Unauthorized': self._unauthorized()
+        if t=='Unauthorized' or (
+            type(t) is not types.StringType and issubclass(t, Unauthorized)
+            ):
+            self._unauthorized()
 
         stb=tb