pythondotorg
pythondotorg copied to clipboard
fix(sentry#6931306293): fix issue with url context resolver
Description
- When browsing somewhere nonexistent we crash and throw a Sentry error:
https://www.python.org/search/?q=about&page=45 leads to:
which fails loading JS and the title bar is also funky:
(InteractiveConsole)
>>> from django.test import RequestFactory
>>>
>>> from pydotorg import context_processors
>>>
>>> factory = RequestFactory()
File "<console>", line 1
factory = RequestFactory()
IndentationError: unexpected indent
>>> factory = RequestFactory()
>>> request = factory.get('/this-does-not-exist/')
>>> result = context_processors.url_name(request)
>>> print(result)
{'URL_NAMESPACE': None, 'URL_NAME': None}
>>> request = factory.get('/about/')
>>> result = context_processors.url_name(request)
>>>
>>> print(result)
{'URL_NAMESPACE': '', 'URL_NAME': 'about'}
>>>
testing locally we get the right context:
Closes
- Fixes #2792