Skip to content

Commit

Permalink
Bug #1493 — Memoize slugify when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
almet committed Oct 9, 2014
1 parent 7feb638 commit e39dc95
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pelican/tests/test_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def test_template(self):

def test_slugify_category_author(self):
settings = get_settings()
settings['SLUG_SUBSTITUTIONS'] = [ ('C#', 'csharp') ]
settings['SLUG_SUBSTITUTIONS'] = (('C#', 'csharp'),)
settings['ARTICLE_URL'] = '{author}/{category}/{slug}/'
settings['ARTICLE_SAVE_AS'] = '{author}/{category}/{slug}/index.html'
article_kwargs = self._copy_page_kwargs()
Expand Down
2 changes: 2 additions & 0 deletions pelican/urlwrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def _key(self):
return self.slug

def _normalize_key(self, key):
if hasattr(key, 'name'):
key = key.name
subs = self.settings.get('SLUG_SUBSTITUTIONS', ())
return six.text_type(slugify(key, subs))

Expand Down
2 changes: 1 addition & 1 deletion pelican/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def pelican_open(filename):
content = content[1:]
yield content


@memoized
def slugify(value, substitutions=()):
"""
Normalizes string, converts to lowercase, removes non-alpha characters,
Expand Down

0 comments on commit e39dc95

Please sign in to comment.