provide separate 'normalizeName()' method

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3925 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2010-07-25 15:58:28 +00:00
parent 8ecf2645f1
commit 2fb16b5c24

View file

@ -224,6 +224,13 @@ class NameChooser(BaseNameChooser):
return self.normalizeName(title)
def normalizeName(self, baseName):
return normalizeName(baseName)
def normalizeName(baseName):
specialCharacters = {
'\xc4': 'Ae', '\xe4': 'ae', '\xd6': 'Oe', '\xf6': 'oe',
'\xdc': 'Ue', '\xfc': 'ue', '\xdf': 'ss'}
result = []
for c in baseName:
try:
@ -235,9 +242,9 @@ class NameChooser(BaseNameChooser):
# separator and special characters to keep
result.append(c)
continue
if c in self.specialCharacters:
if c in specialCharacters:
# transform umlauts and other special characters
result.append(self.specialCharacters[c].lower())
result.append(specialCharacters[c].lower())
continue
if ord(c) > 127:
# map to ASCII characters
@ -253,10 +260,6 @@ class NameChooser(BaseNameChooser):
name = unicode(''.join(result))
return name
specialCharacters = {
'\xc4': 'Ae', '\xe4': 'ae', '\xd6': 'Oe', '\xf6': 'oe',
'\xdc': 'Ue', '\xfc': 'ue', '\xdf': 'ss'}
# virtual attributes/properties