Rename inner wrapped to improve traceback clarity.

Because "line 77, in wrapped_transaction" is at least slightly
better than "in wrapped".
This commit is contained in:
voussoir 2018-02-25 17:15:35 -08:00
parent c001b0fc87
commit 3d925c1426

View file

@ -21,9 +21,9 @@ def required_feature(features):
if isinstance(features, str): if isinstance(features, str):
features = [features] features = [features]
def wrapper(function): def wrapper(method):
@functools.wraps(function) @functools.wraps(method)
def wrapped(self, *args, **kwargs): def wrapped_required_feature(self, *args, **kwargs):
photodb = _get_relevant_photodb(self) photodb = _get_relevant_photodb(self)
config = photodb.config['enable_feature'] config = photodb.config['enable_feature']
@ -36,12 +36,12 @@ def required_feature(features):
for piece in pieces: for piece in pieces:
cfg = cfg[piece] cfg = cfg[piece]
if cfg is False: if cfg is False:
raise exceptions.FeatureDisabled(function.__qualname__) raise exceptions.FeatureDisabled(method.__qualname__)
if cfg is not True: if cfg is not True:
raise ValueError('Bad required_feature "%s" led to %s' % (feature, cfg)) raise ValueError('Bad required_feature "%s" led to %s' % (feature, cfg))
return function(self, *args, **kwargs) return method(self, *args, **kwargs)
return wrapped return wrapped_required_feature
return wrapper return wrapper
def not_implemented(function): def not_implemented(function):
@ -70,7 +70,7 @@ def transaction(method):
If the method fails, roll back to that savepoint. If the method fails, roll back to that savepoint.
''' '''
@functools.wraps(method) @functools.wraps(method)
def wrapped(self, *args, **kwargs): def wrapped_transaction(self, *args, **kwargs):
photodb = _get_relevant_photodb(self) photodb = _get_relevant_photodb(self)
photodb.savepoint() photodb.savepoint()
try: try:
@ -80,4 +80,4 @@ def transaction(method):
raise raise
else: else:
return result return result
return wrapped return wrapped_transaction