From 06c811d85852e0148c97770139aee4928b0c4f1f Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 19 Sep 2020 03:24:02 -0700 Subject: [PATCH] Move all get_user_id_or_none calls to "these might raise" portions. --- etiquette/photodb.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index ffe43fd..f61d8a3 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -79,13 +79,12 @@ class PDBAlbumMixin: # These might raise exceptions. title = objects.Album.normalize_title(title) description = objects.Album.normalize_description(description) + author_id = self.get_user_id_or_none(author) # Ok. album_id = self.generate_id(table='albums') self.log.debug('New Album: %s %s', album_id, title) - author_id = self.get_user_id_or_none(author) - data = { 'id': album_id, 'title': title, @@ -164,13 +163,12 @@ class PDBBookmarkMixin: # These might raise exceptions. title = objects.Bookmark.normalize_title(title) url = objects.Bookmark.normalize_url(url) + author_id = self.get_user_id_or_none(author) # Ok. bookmark_id = self.generate_id(table='bookmarks') self.log.debug('New Bookmark: %s %s %s', bookmark_id, title, url) - author_id = self.get_user_id_or_none(author) - data = { 'id': bookmark_id, 'author_id': author_id, @@ -471,12 +469,12 @@ class PDBPhotoMixin: if not allow_duplicates: self.assert_no_such_photo_by_path(filepath=filepath) + author_id = self.get_user_id_or_none(author) + # Ok. photo_id = self.generate_id(table='photos') self.log.debug('New Photo: %s %s', photo_id, filepath.absolute_path) - author_id = self.get_user_id_or_none(author) - data = { 'id': photo_id, 'filepath': filepath.absolute_path, @@ -1168,13 +1166,12 @@ class PDBTagMixin: self.assert_no_such_tag(name=tagname) description = objects.Tag.normalize_description(description) + author_id = self.get_user_id_or_none(author) # Ok. tag_id = self.generate_id(table='tags') self.log.debug('New Tag: %s %s', tag_id, tagname) - author_id = self.get_user_id_or_none(author) - self.caches['tag_exports'].clear() data = {