diff --git a/etiquette/photodb.py b/etiquette/photodb.py index ae8ae00..b1d9083 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -928,7 +928,7 @@ class PDBTagMixin: tag = objects.Tag(self, [tagid, tagname]) return tag - def normalize_tagname(self, tagname, warning_bag=None): + def normalize_tagname(self, tagname): ''' Tag names can only consist of characters defined in the config. The given tagname is lowercased, gets its spaces and hyphens @@ -943,20 +943,10 @@ class PDBTagMixin: tagname = ''.join(tagname) if len(tagname) < self.config['min_tag_name_length']: - exc = exceptions.TagTooShort(original_tagname) - if warning_bag is not None: - warning_bag.add(exc.error_message) - return None - else: - raise exc + raise exceptions.TagTooShort(original_tagname) elif len(tagname) > self.config['max_tag_name_length']: - exc = exceptions.TagTooLong(tagname) - if warning_bag is not None: - warning_bag.add(exc.error_message) - return None - else: - raise exc + raise exceptions.TagTooLong(tagname) else: return tagname @@ -1280,7 +1270,7 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs ''' output_notes = [] def create_or_get(name): - print('cog', name) + #print('cog', name) try: item = self.get_tag(name) note = ('existing_tag', item.qualified_name()) diff --git a/etiquette/searchhelpers.py b/etiquette/searchhelpers.py index dae8d9f..dabed69 100644 --- a/etiquette/searchhelpers.py +++ b/etiquette/searchhelpers.py @@ -309,12 +309,17 @@ def normalize_tag_mmf(tags, photodb, warning_bag=None): try: tag = photodb.get_tag(name=tag) + exc = None except exceptions.NoSuchTag as e: + exc = e + except (exceptions.TagTooShort, exceptions.TagTooLong) as e: + exc = exceptions.NoSuchTag(tag) + if exc: if warning_bag: - warning_bag.add(e.error_message) + warning_bag.add(exc.error_message) continue else: - raise + raise exc tagset.add(tag) if len(tagset) == 0: diff --git a/etiquette_site.py b/etiquette_site.py index b2226cb..b5eb9e6 100644 --- a/etiquette_site.py +++ b/etiquette_site.py @@ -63,7 +63,6 @@ def delete_tag(tag): def delete_synonym(synonym): synonym = synonym.split('+')[-1].split('.')[-1] - synonym = P.normalize_tagname(synonym) try: master_tag = P.get_tag(synonym) @@ -708,7 +707,7 @@ def post_tag_create_delete_core(tagname, function): 'error_message': e.error_message, } status = 400 - print(response) + #print(response) return jsonify.make_json_response(response, status=status)