[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - BaseRequest.py:1.53 BaseResponse.py:1.18 Client.py:1.46 HTTPRequest.py:1.93 HTTPResponse.py:1.77 Publish.py:1.166 Test.py:1.41 __init__.py:1.13

Tres Seaver cvs-admin at zope.org
Tue Nov 18 08:17:48 EST 2003


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

Modified Files:
	BaseRequest.py BaseResponse.py Client.py HTTPRequest.py 
	HTTPResponse.py Publish.py Test.py __init__.py 
Log Message:
 - Merge tseaver-strexp_delenda-branch to the head.


=== Zope/lib/python/ZPublisher/BaseRequest.py 1.52 => 1.53 ===
--- Zope/lib/python/ZPublisher/BaseRequest.py:1.52	Tue Oct 14 05:08:44 2003
+++ Zope/lib/python/ZPublisher/BaseRequest.py	Tue Nov 18 08:17:17 2003
@@ -17,6 +17,7 @@
 
 from urllib import quote
 import xmlrpc
+from zExceptions import Forbidden
 
 UNSPECIFIED_ROLES=''
 
@@ -499,7 +500,7 @@
 
     if keys is None:
         # Not a named group, so don't go further
-        raise 'Forbidden', (
+        raise Forbidden, (
             """<strong>You are not authorized to access this resource""")
 
     return None


=== Zope/lib/python/ZPublisher/BaseResponse.py 1.17 => 1.18 ===
--- Zope/lib/python/ZPublisher/BaseResponse.py:1.17	Tue Aug 20 23:09:31 2002
+++ Zope/lib/python/ZPublisher/BaseResponse.py	Tue Nov 18 08:17:17 2003
@@ -17,7 +17,8 @@
 
 import  types, sys
 from types import StringType, InstanceType
-from zExceptions import Unauthorized
+from zExceptions import Unauthorized, Forbidden
+from zExceptions import NotFound, BadRequest
 
 class BaseResponse:
     """Base Response Class
@@ -139,19 +140,19 @@
     def notFoundError(self, v=''):
         """Generate an error indicating that an object was not found.
         """
-        raise 'Not Found', v
+        raise NotFound, v
 
     def debugError(self, v=''):
         """Raise an error with debigging info and in debugging mode"""
-        raise 'Debug Error', v
+        raise NotFound, "Debugging notice: %s" % v
 
     def badRequestError(self, v=''):
         """Raise an error indicating something wrong with the request"""
-        raise 'Bad Request', v
+        raise BadRequest, v
 
     def forbiddenError(self, v=''):
         """Raise an error indicating that the request cannot be done"""
-        raise 'Forbidden', v
+        raise Forbidden, v
 
     def unauthorized(self):
         """Raise an eror indicating that the user was not authizated


=== Zope/lib/python/ZPublisher/Client.py 1.45 => 1.46 ===
--- Zope/lib/python/ZPublisher/Client.py:1.45	Wed Aug 14 18:09:40 2002
+++ Zope/lib/python/ZPublisher/Client.py	Tue Nov 18 08:17:17 2003
@@ -44,6 +44,9 @@
 from string import translate, maketrans
 from urlparse import urlparse
 
+class BadReply(Exception):
+    pass
+
 class Function:
     username=None
     password=None
@@ -213,9 +216,9 @@
             try:
                 [ver, ec, em] = line.split(None, 2)
             except ValueError:
-                raise 'BadReply','Bad reply from server: '+line
+                raise BadReply,'Bad reply from server: '+line
             if ver[:5] != 'HTTP/':
-                raise 'BadReply','Bad reply from server: '+line
+                raise BadReply,'Bad reply from server: '+line
 
             ec=int(ec)
             em=em.strip()


=== Zope/lib/python/ZPublisher/HTTPRequest.py 1.92 => 1.93 ===
--- Zope/lib/python/ZPublisher/HTTPRequest.py:1.92	Tue Nov  4 14:23:53 2003
+++ Zope/lib/python/ZPublisher/HTTPRequest.py	Tue Nov 18 08:17:17 2003
@@ -56,6 +56,10 @@
 TAINTING_ENABLED  = tainting_env not in ('disabled', '0', 'no')
 
 _marker=[]
+
+class NestedLoopExit( Exception ):
+    pass
+
 class HTTPRequest(BaseRequest):
     """\
     Model HTTP request data.
@@ -886,8 +890,8 @@
                                                 for origitem in l:
                                                     if not hasattr(origitem, k):
                                                         missesdefault = 1
-                                                        raise "Break"
-                                        except "Break":
+                                                        raise NestedLoopExit
+                                        except NestedLoopExit:
                                             break
                                     else:
                                         if not defitem in l:


=== Zope/lib/python/ZPublisher/HTTPResponse.py 1.76 => 1.77 ===
--- Zope/lib/python/ZPublisher/HTTPResponse.py:1.76	Tue Jul  8 01:54:11 2003
+++ Zope/lib/python/ZPublisher/HTTPResponse.py	Tue Nov 18 08:17:17 2003
@@ -19,15 +19,12 @@
 import zlib, struct
 from string import translate, maketrans
 from BaseResponse import BaseResponse
-from zExceptions import Unauthorized
+from zExceptions import Unauthorized, Redirect
 from zExceptions.ExceptionFormatter import format_exception
+from ZPublisher import BadRequest, InternalError, NotFound
 
 nl2sp = maketrans('\n',' ')
 
-BadRequest = 'BadRequest'
-InternalError = 'InternalError'
-NotFound = 'NotFound'
-
 
 # Enable APPEND_TRACEBACKS to make Zope append tracebacks like it used to,
 # but a better solution is to make standard_error_message display error_tb.
@@ -215,13 +212,20 @@
             # It has already been determined.
             return
 
+        if (isinstance(status, types.ClassType)
+         and issubclass(status, Exception)):
+            status = status.__name__
+
         if isinstance(status, str):
             status = status.lower()
+
         if status_codes.has_key(status):
             status = status_codes[status]
         else:
             status = 500
+
         self.status = status
+
         if reason is None:
             if status_reasons.has_key(status):
                 reason = status_reasons[status]
@@ -725,6 +729,13 @@
                     self.setStatus(302)
                 self.setHeader('location', v)
                 tb = None # just one path covered
+                return self
+            elif isinstance(v, Redirect): # death to string exceptions!
+                if self.status == 300:
+                    self.setStatus(302)
+                self.setHeader('location', v.args[0])
+                self.setBody('')
+                tb = None
                 return self
             else:
                 try:


=== Zope/lib/python/ZPublisher/Publish.py 1.165 => 1.166 ===
--- Zope/lib/python/ZPublisher/Publish.py:1.165	Tue Oct 21 10:10:16 2003
+++ Zope/lib/python/ZPublisher/Publish.py	Tue Nov 18 08:17:17 2003
@@ -20,6 +20,7 @@
 from Request import Request
 from maybe_lock import allocate_lock
 from mapply import mapply
+from zExceptions import Redirect
 
 class Retry(Exception):
     """Raise this to retry a request
@@ -69,7 +70,8 @@
         # First check for "cancel" redirect:
         if request_get('SUBMIT','').strip().lower()=='cancel':
             cancel=request_get('CANCEL_ACTION','')
-            if cancel: raise 'Redirect', cancel
+            if cancel:
+                raise Redirect, cancel
 
         after_list[0]=bobo_after
         if debug_mode: response.debug_mode=debug_mode


=== Zope/lib/python/ZPublisher/Test.py 1.40 => 1.41 ===
--- Zope/lib/python/ZPublisher/Test.py:1.40	Wed Aug 14 18:09:40 2002
+++ Zope/lib/python/ZPublisher/Test.py	Tue Nov 18 08:17:17 2003
@@ -130,11 +130,12 @@
             repeat_count=int(val)
         elif opt=='-e':
             opt=val.find('=')
-            if opt <= 0: raise 'Invalid argument to -e', val
+            if opt <= 0: raise ValueError, 'Invalid argument to -e: %s' % val
             env[val[:opt]]=val[opt+1:]
 
     if (debug or 0)+(timeit or 0)+(profile and 1 or 0) > 1:
-        raise 'Invalid options', 'only one of -p, -t, and -d are allowed'
+        raise ValueError, (
+          'Invalid options: only one of -p, -t, and -d are allowed')
 
     module=args[0]
 


=== Zope/lib/python/ZPublisher/__init__.py 1.12 => 1.13 ===
--- Zope/lib/python/ZPublisher/__init__.py:1.12	Wed Aug 14 18:09:40 2002
+++ Zope/lib/python/ZPublisher/__init__.py	Tue Nov 18 08:17:17 2003
@@ -19,6 +19,7 @@
 if not hasattr(sys, 'argv'):
     sys.argv=[]
 
+from zExceptions import NotFound, BadRequest, InternalError, Forbidden
 
 from Publish import publish_module, Retry
 




More information about the Zope-Checkins mailing list