1
0
Fork 0
forked from github/pelican

Don't process metadata links before all files are present.

The refresh_metadata_intersite_links() is called again later, so this
bit was only causing everything to be processed twice. Besides
that, it makes the processing dependent on file order -- in particular,
when metadata references a file that was not parsed yet, it reported an
"Unable to find" warning. But everything is found in the second pass, so
this only causes a superflous false warning and no change to the output.

The related test now needs to call the
refresh_metadata_intersite_links() explicitly. That function is called
from Pelican.run() and all generators but the test processes just one
page so it has no chance of being called implicitly.

Related discussion: https://github.com/getpelican/pelican/pull/2288/files#r204337359
This commit is contained in:
Vladimír Vondruš 2018-09-12 12:56:24 +02:00
commit 673e33840d
2 changed files with 4 additions and 4 deletions

View file

@ -142,10 +142,6 @@ class Content(object):
if not hasattr(self, 'status'):
self.status = getattr(self, 'default_status', None)
if (len(self._context.get('generated_content', [])) > 0 or
len(self._context.get('static_content', [])) > 0):
self.refresh_metadata_intersite_links()
signals.content_object_init.send(self)
def __str__(self):

View file

@ -333,6 +333,10 @@ class TestPage(LoggedTestCase):
args['metadata']['custom'] = parsed
args['context']['localsiteurl'] = 'http://notmyidea.org'
p = Page(**args)
# This is called implicitly from all generators and Pelican.run() once
# all files are processed. Here we process just one page so it needs
# to be called explicitly.
p.refresh_metadata_intersite_links()
self.assertEqual(p.summary, linked)
self.assertEqual(p.custom, linked)