From 6116236ed9a2bf245df2f34361431fb2515b54ab Mon Sep 17 00:00:00 2001 From: Pavel Puchkin Date: Wed, 18 Apr 2012 18:56:53 +1100 Subject: [PATCH] `*_SAVE_AS` = None fix Ability to disable creating some files when their `_SAVE_AS` setting is set to none-value. Mostly for disabling creating of `authors` stuff (when there only one user, see #320 for details) --- pelican/contents.py | 3 ++- pelican/writers.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pelican/contents.py b/pelican/contents.py index 593822a9..8174f05a 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -183,7 +183,8 @@ class URLWrapper(object): def _from_settings(self, key): setting = "%s_%s" % (self.__class__.__name__.upper(), key) - return unicode(self.settings[setting]).format(**self.as_dict()) + value = self.settings[setting] or '' + return unicode(value).format(**self.as_dict()) url = property(functools.partial(_from_settings, key='URL')) save_as = property(functools.partial(_from_settings, key='SAVE_AS')) diff --git a/pelican/writers.py b/pelican/writers.py index faca46bd..058be333 100644 --- a/pelican/writers.py +++ b/pelican/writers.py @@ -99,6 +99,8 @@ class Writer(object): :param **kwargs: additional variables to pass to the templates """ + if not name: return + def _write_file(template, localcontext, output_path, name): """Render the template write the file.""" old_locale = locale.setlocale(locale.LC_ALL)