Commit 9d2429a0 authored by 's avatar

Added an "abort" flag to RESPONSE.exception, so that the method can be

called without necessarily aborting the current transaction. This is
required by things like the resolve_url machinery, where there is a
need to call the exception() method to get a meaningful error. The
resolve_url method in HTTPRequest.Request has been changed to take
advantage of this. The existing semantics of RESPONSE.exception()
are unchanged - it will automatically abort just as it did before
unless you pass the keyword arg abort=0 when calling the method.
parent 8d2817c7
......@@ -83,7 +83,7 @@
#
##############################################################################
__version__='$Revision: 1.23 $'[11:-2]
__version__='$Revision: 1.24 $'[11:-2]
import regex, sys, os, string
from string import lower, atoi, rfind, split, strip, join, upper, find
......@@ -627,13 +627,22 @@ class HTTPRequest(BaseRequest):
rsp=req.response
req['PATH_INFO']=path
object=None
# Try to traverse to get an object. Note that we call
# the exception method on the response, but we don't
# want to actually abort the current transaction
# (which is usually the default when the exception
# method is called on the response).
try: object=req.traverse(path)
except: rsp.exception(0)
if object is None: raise rsp.errmsg, sys.exc_value
# waaa - traversal may return a "default object"
# like an index_html document, though you really
# wanted to get a Folder back :(
except: rsp.exception(abort=0)
if object is None:
raise rsp.errmsg, sys.exc_value
# The traversal machinery may return a "default object"
# like an index_html document. This is not appropriate
# in the context of the resolve_url method so we need
# to ensure we are getting the actual object named by
# the given url, and not some kind of default object.
if hasattr(object, 'id'):
if callable(object.id):
name=object.id()
......
......@@ -84,8 +84,8 @@
##############################################################################
'''CGI Response Output formatter
$Id: HTTPResponse.py,v 1.19 1999/08/18 00:23:50 amos Exp $'''
__version__='$Revision: 1.19 $'[11:-2]
$Id: HTTPResponse.py,v 1.20 1999/09/01 00:25:48 brian Exp $'''
__version__='$Revision: 1.20 $'[11:-2]
import string, types, sys, regex
from string import find, rfind, lower, upper, strip, split, join, translate
......@@ -557,6 +557,7 @@ class HTTPResponse(BaseResponse):
"$"
).match,
tag_search=regex.compile('[a-zA-Z]>').search,
abort=1
):
if type(info) is type(()) and len(info)==3: t,v,tb = info
else: t,v,tb = sys.exc_info()
......@@ -565,9 +566,10 @@ class HTTPResponse(BaseResponse):
stb=tb
# Abort running transaction, if any:
try: get_transaction().abort()
except: pass
# Abort running transaction, if any
if abort:
try: get_transaction().abort()
except: pass
try:
# Try to capture exception info for bci calls
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment