Skip to content

Commit

Permalink
fix some invalid values due to race conditions
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 7, 2015
1 parent 67c5fb2 commit 2af18fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Features
Bugfixes
--------

* Fixed a ``TranslatableSetting.langformat`` race condition
* Fixed ``TranslatableSetting`` instantiation in
``TranslatableSetting.langformat`` (Issue #1571)
* Fixed ``rss.xsl`` path for blogs not deployed to server root
Expand Down
7 changes: 6 additions & 1 deletion nikola/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,10 @@ def langformat(self, formats):
for a in f[0] + tuple(f[1].values()):
if isinstance(a, dict):
langkeys += list(a)

# Now that we know all this, we go through all the languages we have.
allvalues = set(keys + langkeys + list(self.values))
self.values['__orig__'] = self.values[self.default_lang]
for l in allvalues:
if l in keys:
oargs, okwargs = formats[l]
Expand All @@ -409,7 +411,10 @@ def langformat(self, formats):
else:
kwargs.update({k: v})

self.values[l] = self.values[l].format(*args, **kwargs)
if l in self.values:
self.values[l] = self.values[l].format(*args, **kwargs)
else:
self.values[l] = self.values['__orig__'].format(*args, **kwargs)
self.values.default_factory = lambda: self.values[self.default_lang]

return self
Expand Down

0 comments on commit 2af18fb

Please sign in to comment.