diff --git a/etiquette/objects.py b/etiquette/objects.py index 0368cbb..ea33dc6 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -248,8 +248,7 @@ class Album(ObjectBase, GroupableMixin): self._sum_bytes_recursive = None parent = self.parent() if parent is not None: - parent._sum_photos_recursive = None - parent._sum_bytes_recursive = None + parent._uncache_sums() @decorators.required_feature('album.edit') def add_child(self, *args, **kwargs): @@ -301,7 +300,8 @@ class Album(ObjectBase, GroupableMixin): raise ValueError('Not the same PhotoDB') if self.has_photo(photo): return - self.photodb.log.debug('Adding photo %s to %s' % (photo, self)) + + self.photodb.log.debug('Adding photo %s to %s', photo, self) cur = self.photodb.sql.cursor() cur.execute('INSERT INTO album_photo_rel VALUES(?, ?)', [self.id, photo.id]) self._uncache_sums() @@ -428,6 +428,8 @@ class Album(ObjectBase, GroupableMixin): def remove_photo(self, photo, *, commit=True): if not self.has_photo(photo): return + + self.photodb.log.debug('Removing photo %s from %s', photo, self) cur = self.photodb.sql.cursor() cur.execute( 'DELETE FROM album_photo_rel WHERE albumid == ? AND photoid == ?', @@ -1061,7 +1063,6 @@ class Tag(ObjectBase, GroupableMixin): def add_synonym(self, synname, *, commit=True): synname = self.photodb.normalize_tagname(synname) - print(synname, self.name) if synname == self.name: raise exceptions.CantSynonymSelf() @@ -1072,6 +1073,8 @@ class Tag(ObjectBase, GroupableMixin): else: raise exceptions.TagExists(existing_tag) + self.log.debug('New synonym %s of %s', synname, self.name) + self.photodb._cached_frozen_children = None cur = self.photodb.sql.cursor() cur.execute('INSERT INTO tag_synonyms VALUES(?, ?)', [synname, self.name]) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index b58cf65..6adb177 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -241,7 +241,7 @@ class PDBAlbumMixin: cur = self.sql.cursor() - self.log.debug('New Album: %s' % title) + self.log.debug('New Album: %s %s', album_id, title) data = { 'id': album_id, 'title': title, @@ -386,7 +386,7 @@ class PDBPhotoMixin: else: raise exceptions.PhotoExists(existing) - self.log.debug('New Photo: %s' % filepath.absolute_path) + self.log.debug('New Photo: %s', filepath.absolute_path) author_id = self.get_user_id_or_none(author) created = int(helpers.now()) @@ -911,6 +911,8 @@ class PDBTagMixin: else: raise exceptions.TagExists(existing_tag) + self.log.debug('New Tag: %s', tagname) + tagid = self.generate_id('tags') self._cached_frozen_children = None cur = self.sql.cursor() @@ -1076,6 +1078,8 @@ class PDBUserMixin: else: raise exceptions.UserExists(existing_user) + self.log.debug('New User: %s', username) + user_id = self.generate_user_id() hashed_password = bcrypt.hashpw(password, bcrypt.gensalt()) created = int(helpers.now()) @@ -1389,7 +1393,6 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs synonym = tag.add_synonym(synonym) note = ('new_synonym', '%s+%s' % (tag.name, synonym)) output_notes.append(note) - print('New syn %s' % synonym) return output_notes def generate_id(self, table):