diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/conf/global_settings.py | 14 | ||||
| -rw-r--r-- | django/middleware/common.py | 24 |
2 files changed, 28 insertions, 10 deletions
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py index 1ab9b498a9..477f13b675 100644 --- a/django/conf/global_settings.py +++ b/django/conf/global_settings.py @@ -246,9 +246,17 @@ ALLOWED_INCLUDE_ROOTS = () # is an admin. ADMIN_FOR = () -# 404s that may be ignored. -IGNORABLE_404_STARTS = ('/cgi-bin/', '/_vti_bin', '/_vti_inf') -IGNORABLE_404_ENDS = ('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', 'favicon.ico', '.php') +# List of compiled regular expression objects representing URLs that need not +# be reported when SEND_BROKEN_LINK_EMAILS is True. Here are a few examples: +# import re +# IGNORABLE_404_URLS = ( +# re.compile(r'^/apple-touch-icon.*\.png$'), +# re.compile(r'^/favicon.ico$), +# re.compile(r'^/robots.txt$), +# re.compile(r'^/phpmyadmin/), +# re.compile(r'\.(cgi|php|pl)$'), +# ) +IGNORABLE_404_URLS = () # A secret key for this particular Django installation. Used in secret-key # hashing algorithms. Set this in your settings, or Django will complain diff --git a/django/middleware/common.py b/django/middleware/common.py index eb145edf19..689929bea4 100644 --- a/django/middleware/common.py +++ b/django/middleware/common.py @@ -127,13 +127,23 @@ def _is_ignorable_404(uri): """ Returns True if a 404 at the given URL *shouldn't* notify the site managers. """ - for start in settings.IGNORABLE_404_STARTS: - if uri.startswith(start): - return True - for end in settings.IGNORABLE_404_ENDS: - if uri.endswith(end): - return True - return False + if getattr(settings, 'IGNORABLE_404_STARTS', ()): + import warnings + warnings.warn('The IGNORABLE_404_STARTS setting has been deprecated ' + 'in favour of IGNORABLE_404_URLS.', + PendingDeprecationWarning) + for start in settings.IGNORABLE_404_STARTS: + if uri.startswith(start): + return True + if getattr(settings, 'IGNORABLE_404_ENDS', ()): + import warnings + warnings.warn('The IGNORABLE_404_ENDS setting has been deprecated ' + 'in favour of IGNORABLE_404_URLS.', + PendingDeprecationWarning) + for end in settings.IGNORABLE_404_ENDS: + if uri.endswith(end): + return True + return any(pattern.search(uri) for pattern in settings.IGNORABLE_404_URLS) def _is_internal_request(domain, referer): """ |
