From 57a9e0d4dcee9e4fa4d8fd4838ac4dcfd8d73b92 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 15 Jul 2018 13:27:04 -0700 Subject: [PATCH] Move PDB.close out of the sqlmixin, into main class. Doesn't really deserve to be with the sql stuff. --- etiquette/photodb.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index d12a47b..11131da 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -675,17 +675,6 @@ class PDBSQLMixin: self.on_commit_queue = [] self.savepoints = [] - def close(self): - # Wrapped in hasattr because if the object fails __init__, Python will - # still call __del__ and thus close(), even though the attributes - # we're trying to clean up never got set. - if hasattr(self, 'sql'): - self.sql.close() - - if hasattr(self, 'ephemeral'): - if self.ephemeral: - self.ephemeral_directory.cleanup() - def commit(self): while len(self.on_commit_queue) > 0: task = self.on_commit_queue.pop() @@ -1363,6 +1352,16 @@ class PhotoDB( self._cached_frozen_children = None self._cached_qualname_map = None + def close(self): + # Wrapped in hasattr because if the object fails __init__, Python will + # still call __del__ and thus close(), even though the attributes + # we're trying to clean up never got set. + if hasattr(self, 'sql'): + self.sql.close() + + if getattr(self, 'ephemeral', False): + self.ephemeral_directory.cleanup() + def generate_id(self, table): ''' Create a new ID number that is unique to the given table.