Replace PhotoDB.normalize_tagname with real call to Tag.norm_name.
I originally did this because I didn't want to accidentally call Tag.normalize_name and forget to pass the valid parameters. However, having this single method be on PhotoDB while the other norms are part of their proper class has been an eyesore. So since there are only a few calls to this I'm just inlining them and trusting to not forget if I add more in the future.
This commit is contained in:
parent
8c74e42a74
commit
a9865d8546
1 changed files with 12 additions and 11 deletions
|
@ -828,7 +828,12 @@ class PDBTagMixin:
|
||||||
tagname = tagname.tagname
|
tagname = tagname.tagname
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tagname = self.normalize_tagname(tagname)
|
tagname = objects.Tag.normalize_name(
|
||||||
|
tagname,
|
||||||
|
valid_chars=self.config['tag']['valid_chars'],
|
||||||
|
min_length=self.config['tag']['min_length'],
|
||||||
|
max_length=self.config['tag']['max_length'],
|
||||||
|
)
|
||||||
except (exceptions.TagTooShort, exceptions.TagTooLong):
|
except (exceptions.TagTooShort, exceptions.TagTooLong):
|
||||||
raise exceptions.NoSuchTag(tagname)
|
raise exceptions.NoSuchTag(tagname)
|
||||||
|
|
||||||
|
@ -865,7 +870,12 @@ class PDBTagMixin:
|
||||||
'''
|
'''
|
||||||
Register a new tag and return the Tag object.
|
Register a new tag and return the Tag object.
|
||||||
'''
|
'''
|
||||||
tagname = self.normalize_tagname(tagname)
|
tagname = objects.Tag.normalize_name(
|
||||||
|
tagname,
|
||||||
|
valid_chars=self.config['tag']['valid_chars'],
|
||||||
|
min_length=self.config['tag']['min_length'],
|
||||||
|
max_length=self.config['tag']['max_length'],
|
||||||
|
)
|
||||||
self.assert_no_such_tag(name=tagname)
|
self.assert_no_such_tag(name=tagname)
|
||||||
|
|
||||||
description = objects.Tag.normalize_description(description)
|
description = objects.Tag.normalize_description(description)
|
||||||
|
@ -888,15 +898,6 @@ class PDBTagMixin:
|
||||||
tag = self.get_cached_instance('tag', data)
|
tag = self.get_cached_instance('tag', data)
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
def normalize_tagname(self, tagname):
|
|
||||||
tagname = objects.Tag.normalize_name(
|
|
||||||
tagname,
|
|
||||||
valid_chars=self.config['tag']['valid_chars'],
|
|
||||||
min_length=self.config['tag']['min_length'],
|
|
||||||
max_length=self.config['tag']['max_length'],
|
|
||||||
)
|
|
||||||
return tagname
|
|
||||||
|
|
||||||
|
|
||||||
class PDBUserMixin:
|
class PDBUserMixin:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
Loading…
Reference in a new issue