From b572cbeef15ac2e4fe6107110f52fbdc212cd52a Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Tue, 27 May 2014 11:42:37 -0700 Subject: [PATCH] Addressed comments from @avaris in PR getpelican/pelican#1348 --- pelican/settings.py | 2 +- pelican/utils.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pelican/settings.py b/pelican/settings.py index f49d3bd4..6845b830 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -70,7 +70,7 @@ DEFAULT_CONFIG = { 'DRAFT_LANG_SAVE_AS': os.path.join('drafts', '{slug}-{lang}.html'), 'PAGE_URL': 'pages/{slug}.html', 'PAGE_SAVE_AS': os.path.join('pages', '{slug}.html'), - 'PAGE_ORDER_BY': 'filename', + 'PAGE_ORDER_BY': 'basename', 'PAGE_LANG_URL': 'pages/{slug}-{lang}.html', 'PAGE_LANG_SAVE_AS': os.path.join('pages', '{slug}-{lang}.html'), 'STATIC_URL': '{path}', diff --git a/pelican/utils.py b/pelican/utils.py index 076c41ea..c2d6ca22 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -473,7 +473,12 @@ def process_translations(content_list, order_by=None): elif order_by == 'basename': index.sort(key=lambda x: os.path.basename(x.source_path or '')) elif order_by != 'slug': - index.sort(key=attrgetter(order_by)) + try: + index.sort(key=attrgetter(order_by)) + except AttributeError: + error_msg = ('There is no "{}" attribute in the item metadata.' + 'Defaulting to slug order.') + logger.warning(error_msg.format(order_by)) return index, translations