Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: cms/sources.py

Issue 30044555: Issue 7461 - Include source page into warning text for unresolved links (Closed) Base URL: https://hg.adblockplus.org/cms
Patch Set: Improve readability of the error message Created April 15, 2019, 4:48 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cms/converters.py ('k') | tests/expected_output/common/en/sitemap » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/sources.py
===================================================================
--- a/cms/sources.py
+++ b/cms/sources.py
@@ -22,17 +22,17 @@
from random import randint
import urlparse
import logging
from cms import utils
class Source:
- def resolve_link(self, url, locale):
+ def resolve_link(self, url, locale, source_page=None):
parsed = urlparse.urlparse(url)
page = parsed.path
if parsed.scheme != '' or page.startswith('/') or page.startswith('.'):
# Not a page link
return None, None
if url.startswith('tel:'):
# Workaround for 'tel' scheme not recognized in Python <=2.7.3.
@@ -54,17 +54,18 @@
if not self.has_locale(locale, page):
locale = default_locale
elif self.has_page(alternative_page):
if not self.has_locale(locale, alternative_page):
locale = default_locale
elif self.has_static(page):
locale = None
else:
- logging.warning('Link to %s cannot be resolved', page)
+ logging.warning('Link from "%s" to "%s" cannot be resolved',
+ source_page, page)
parts = page.split('/')
if parts[-1] == default_page:
page = '/'.join(parts[:-1])
if locale:
path = '/{}/{}'.format(locale, page)
return locale, urlparse.urlunparse(parsed[0:2] + (path,) + parsed[3:])
return locale, '/' + page
« no previous file with comments | « cms/converters.py ('k') | tests/expected_output/common/en/sitemap » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld