Move calls to self.app outside of error handling

On py3, if/when you hit an error, you can get very noisy tracebacks like

  <traceback coming out of split_path()>

  During handling of the above exception, another exception occurred:

  <meaningful traceback>

In general, I like this, but when we've used exception handling for
flow-control, it gets difficult to separate the wheat from the chaff.

Change-Id: I5f3bc6416207cab2c7e3a77ee6689360b55990e7
This commit is contained in:
Tim Burke 2019-06-01 10:46:54 -07:00
parent 74e1f2e053
commit 5573354655
8 changed files with 27 additions and 1 deletions

View File

@ -225,7 +225,10 @@ class ServerSideCopyMiddleware(object):
req = Request(env)
try:
(version, account, container, obj) = req.split_path(4, 4, True)
is_obj_req = True
except ValueError:
is_obj_req = False
if not is_obj_req:
# If obj component is not present in req, do not proceed further.
return self.app(env, start_response)

View File

@ -433,7 +433,10 @@ class Decrypter(object):
req = Request(env)
try:
parts = req.split_path(3, 4, True)
is_cont_or_obj_req = True
except ValueError:
is_cont_or_obj_req = False
if not is_cont_or_obj_req:
return self.app(env, start_response)
if parts[3] and req.method in ('GET', 'HEAD'):

View File

@ -420,7 +420,10 @@ class DynamicLargeObject(object):
req = Request(env)
try:
vrs, account, container, obj = req.split_path(4, 4, True)
is_obj_req = True
except ValueError:
is_obj_req = False
if not is_obj_req:
return self.app(env, start_response)
if ((req.method == 'GET' or req.method == 'HEAD') and

View File

@ -128,6 +128,10 @@ class ListingFilter(object):
# account and container only
version, acct, cont = req.split_path(2, 3)
except ValueError:
is_container_req = False
else:
is_container_req = True
if not is_container_req:
return self.app(env, start_response)
if not valid_api_version(version) or req.method not in ('GET', 'HEAD'):

View File

@ -119,7 +119,11 @@ class ListingEtagMiddleware(object):
if not valid_api_version(v):
raise ValueError
except ValueError:
# not a container request; pass through
is_container_req = False
else:
is_container_req = True
if not is_container_req:
# pass through
return self.app(env, start_response)
ctx = WSGIContext(self.app)

View File

@ -1511,7 +1511,10 @@ class StaticLargeObject(object):
req = Request(env)
try:
vrs, account, container, obj = req.split_path(3, 4, True)
is_cont_or_obj_req = True
except ValueError:
is_cont_or_obj_req = False
if not is_cont_or_obj_req:
return self.app(env, start_response)
if not obj:

View File

@ -551,7 +551,10 @@ class SymlinkMiddleware(object):
req = Request(env)
try:
version, acc, cont, obj = req.split_path(3, 4, True)
is_cont_or_obj_req = True
except ValueError:
is_cont_or_obj_req = False
if not is_cont_or_obj_req:
return self.app(env, start_response)
try:

View File

@ -814,7 +814,10 @@ class VersionedWritesMiddleware(object):
req = Request(env)
try:
(api_version, account, container, obj) = req.split_path(3, 4, True)
is_cont_or_obj_req = True
except ValueError:
is_cont_or_obj_req = False
if not is_cont_or_obj_req:
return self.app(env, start_response)
# In case allow_versioned_writes is set in the filter configuration,