diff --git a/etiquette/decorators.py b/etiquette/decorators.py index 0f4b027..9ee6964 100644 --- a/etiquette/decorators.py +++ b/etiquette/decorators.py @@ -78,7 +78,7 @@ def transaction(method): @functools.wraps(method) def wrapped_transaction(self, *args, **kwargs): photodb = _get_relevant_photodb(self) - savepoint_id = photodb.savepoint() + savepoint_id = photodb.savepoint(message=method.__qualname__) try: result = method(self, *args, **kwargs) except Exception as e: diff --git a/etiquette/photodb.py b/etiquette/photodb.py index a13d724..daebe8e 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -720,9 +720,12 @@ class PDBSQLMixin: if item == restore_to: break - def savepoint(self): + def savepoint(self, message=None): savepoint_id = helpers.random_hex(length=16) - self.log.debug('Savepoint %s.', savepoint_id) + if message: + self.log.debug('Savepoint %s for %s.', savepoint_id, message) + else: + self.log.debug('Savepoint %s.', savepoint_id) query = 'SAVEPOINT "%s"' % savepoint_id self.sql.execute(query) self.savepoints.append(savepoint_id)