On Fri, Mar 22, 2013 at 12:25:18AM -0700, Alexis Metaireau wrote:
> > @@ -93,7 +95,8 @@ def __init__(self, content, metadata=None, settings=None,
> >              if hasattr(self, 'lang') and self.lang in settings['DATE_FORMATS']:
> >                  self.date_format = settings['DATE_FORMATS'][self.lang]
> >              else:
> > -                self.date_format = settings['DEFAULT_DATE_FORMAT']
> > +                self.date_format = settings.get(
> > +                    'DEFAULT_DATE_FORMAT', '%a %d %B %Y')
> 
> that should go in settings.py I guess.

Thinking about this more, I've gone the way I have because I expect to
occasionally get arbitrary settings dicts.  Since these dicts may not
have the desired key, we need a default and it's easy to store this
default locally.  Maybe a better approach would be:

  self.date_format = settings.get(
	  'DEFAULT_DATE_FORMAT',
		pelican.settings._DEFAULT_CONFIG['DEFAULT_DATE_FORMAT'])

which could be encapsulated in a pelican.settings.get_setting() helper
function:

  def get_setting(settings, key):
      if key in settings:
          return settings[key]
      return _DEFAULT_CONFIG[key]

which handles the "someone passed me {} as a settings dictionary" case
well.  This would also make the tests cleaner, since many of them
currently copy `_DEFAULT_CONFIG` and tweak a few variables, while with
this approach they could just pass a small dict of overrides.

p.s. I'm not sure why `_DEFAULT_CONFIG` has an underscore.  It is
often accessed by other Pelican modules, including plugins ;).