Skip to content

Commit 5acff0e

Browse files
committed
Added a method Person.ascii_name() for use when generating 1id-*.txt files. Added caching for Person.plain_name(). Fixes a problem with non-ascii names in 1id-*.txt which lead to non-ascii names in xml2rfc reference files.
- Legacy-Id: 11510
1 parent 8642e8d commit 5acff0e

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

ietf/idindex/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def active_drafts_index_by_group(extra_values=()):
239239
if d:
240240
if "authors" not in d:
241241
d["authors"] = []
242-
d["authors"].append(unicode(a.author.person))
242+
d["authors"].append(a.author.person.ascii_name())
243243

244244
# put docs into groups
245245
for d in docs_dict.itervalues():

ietf/person/models.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
22

33
import datetime
4-
from urlparse import urljoin
54
from hashids import Hashids
5+
from unidecode import unidecode
6+
from urlparse import urljoin
67

78
from django.conf import settings
89

@@ -44,8 +45,20 @@ def short(self):
4445
prefix, first, middle, last, suffix = self.ascii_parts()
4546
return (first and first[0]+"." or "")+(middle or "")+" "+last+(suffix and " "+suffix or "")
4647
def plain_name(self):
47-
prefix, first, middle, last, suffix = name_parts(self.name)
48-
return u" ".join([first, last])
48+
if not hasattr(self, '_cached_plain_name'):
49+
prefix, first, middle, last, suffix = name_parts(self.name)
50+
self._cached_plain_name = u" ".join([first, last])
51+
return self._cached_plain_name
52+
def ascii_name(self):
53+
if not hasattr(self, '_cached_ascii_name'):
54+
if self.ascii:
55+
# It's possibly overkill with unidecode() here, but needed until
56+
# we're validating the content of the ascii field, and have
57+
# verified that the field is ascii clean in the database:
58+
self._cached_ascii_name = unidecode(self.ascii)
59+
else:
60+
self._cached_ascii_name = unidecode(self.plain_name())
61+
return self._cached_ascii_name
4962
def initials(self):
5063
return initials(self.ascii or self.name)
5164
def last_name(self):

0 commit comments

Comments
 (0)