Fixing URL bug to allow users to have only one URL rule. #2006

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

Currently Django 1.6 does not allow developers to specify only one URL within the urls.py file. The app_name and namespace attributes don't exist and an exception is thrown if urls.py only contains one URL.

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/Users/dmyerscough/nagios-api-env/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 67, in call
return self.application(environ, start_response)
File "/Users/dmyerscough/nagios-api-env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 206, in call
response = self.get_response(request)
File "/Users/dmyerscough/nagios-api-env/lib/python2.7/site-packages/django/core/handlers/base.py", line 148, in get_response
response = debug.technical_404_response(request, e)
File "/Users/dmyerscough/nagios-api-env/lib/python2.7/site-packages/django/views/debug.py", line 471, in technical_404_response
and tried[0][0].app_name == tried[0][0].namespace == 'admin')):
AttributeError: 'RegexURLPattern' object has no attribute 'app_name'

Steps to reproduce this:-

1 - Edit the urls.py file and include only one URL rule

urlpatterns = patterns('',
url(r'^test/', 'nagios_api.views.comments', name='home'),

2 - Connect to the Django web server and the error above will be reproduced.

@dmyerscough dmyerscough Fixing URL bug to allow users to have only one URL rule. The app_name…
… and namespace attributes dont exist and cause a AttributeError
6bafcb2
Owner

This pull request removes another feature that was added for a good reason (check git blame) instead of fixing the bug.

The correct solution is getattr(tried[0][0], 'app_name', '') == getattr(tried[0][0], 'namespace', '') == 'admin'.

@aaugustin aaugustin closed this Nov 29, 2013
@victorgama victorgama added a commit to victorgama/django that referenced this pull request May 29, 2014
@victorgama victorgama Fixed #21597 -- Recover from faulty connections.
This implements a way of recovering from faulty MySQL Server connections when an error #2006 is issued from the MySQL Connection Adapter.
It renews the (already broken) MySQL Connection and also resets the faulty cursor by replacing its current instance with a brand new one.
38f58aa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment