Skip to content
Permalink
Browse files

Fix json encoder and template hook registries (#1887)

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 11, 2015
1 parent 38750a9 commit e62b74ddf2ab3ae1d09763153fe457bae6d77e3c
Showing with 9 additions and 3 deletions.
  1. +2 −2 nikola/post.py
  2. +7 −1 nikola/utils.py
@@ -438,7 +438,7 @@ def deps(self, lang):
deps.extend([cand_1, cand_2])
deps += self._get_dependencies(self._dependency_file_page[lang])
deps += self._get_dependencies(self._dependency_file_page[None])
return deps
return sorted(deps)

def deps_uptodate(self, lang):
"""Return a list of uptodate dependencies to build this post's page.
@@ -498,7 +498,7 @@ def fragment_deps(self, lang):
deps = [d for d in deps if os.path.exists(d)]
deps += self._get_dependencies(self._dependency_file_fragment[lang])
deps += self._get_dependencies(self._dependency_file_fragment[None])
return deps
return sorted(deps)

def fragment_deps_uptodate(self, lang):
"""Return a list of file dependencies to build this post's fragment."""
@@ -492,13 +492,19 @@ def __hash__(self):
def __str__(self):
return '<TemplateHookRegistry: {0}>'.format(self._items)

def __repr__(self):
return '<TemplateHookRegistry: {0}>'.format(self.name)


class CustomEncoder(json.JSONEncoder):
def default(self, obj):
try:
return super(CustomEncoder, self).default(obj)
except TypeError:
s = repr(obj).split('0x', 1)[0]
if isinstance(obj, set):

This comment has been minimized.

Copy link
@felixfontein

felixfontein Jul 11, 2015

Contributor

Why not include frozenset just in case as well? (Sorry, only added that later to my post...)

return self.encode(sorted(list(obj)))

This comment has been minimized.

Copy link
@felixfontein

felixfontein Jul 12, 2015

Contributor

This will trigger a rebuild of essentially all pages, tag pages and indices. Should we mention this in CHANGES.txt? Something along "Fixed superfluous rebuild problems with Python 3. Note that this will cause rebuilds for most sites. (Issue #1887)" maybe?

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska Jul 12, 2015

Author Member

Do it. (I guess users are accustomed to rebuilds with new releases anyway, I did that a couple of times already…)

This comment has been minimized.

Copy link
@felixfontein

felixfontein Jul 12, 2015

Contributor

That's true. I'll do it.
(I'll also include frozenset.)

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska Jul 12, 2015

Author Member

frozenset is already done

This comment has been minimized.

Copy link
@felixfontein

felixfontein Jul 12, 2015

Contributor

(Ah, frozenset is already there. Only CHANGES.txt, then.)

else:
s = repr(obj).split('0x', 1)[0]
return s


0 comments on commit e62b74d

Please sign in to comment.
You can’t perform that action at this time.