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: Add tests Created April 12, 2019, 2:37 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
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 to "%s" (from "%s") cannot be resolved',
+ page, source_page)
rhowell 2019/04/12 20:17:12 NIT: It might be slightly easier to read the error
Vasily Kuznetsov 2019/04/15 16:48:45 Yeah, makes sense. Done.
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

Powered by Google App Engine
This is Rietveld