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 |