Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#15343 closed (fixed)

import of handler500 is missing in django/contrib/auth/tests/urls.py

Reported by: Marco De Paoli Owned by: nobody
Component: Contrib apps Version: 1.2
Severity: Keywords: urls handler500
Cc: Marco De Paoli, afitzpatrick Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

as documented here http://code.djangoproject.com/ticket/11013#comment:1

all urls files must contain

from django.conf.urls.defaults import *

or an explicit import for the function handler404 and handler500 ex.

from django.conf.urls.defaults import handler404, handler500

but the file django/contrib/auth/tests/urls.py doesn't follow this rule

the consequence is that any problem that arise inside auth tests is signaled as

AttributeError: 'module' object has no attribute 'handler500'

as a temporary workaround I used this method:

  • modify django/contrib/auth/tests/urls.py to add an explict import for handler500
  • run auth test cases and obtain the correct error message
  • restore django/contrib/auth/tests/urls.py

Nevertheless this case shows another problem

When Django outputs:

AttributeError: 'module' object has no attribute 'handler500'

it doesn't signal which file is missing handler500, and this makes the research a little bit hard

My advice is to modify slightly the urlresolver mechanism (django/core/urlresolvers.py)

for example the instruction

callback = getattr(self.urlconf_module, 'handler%s' % view_type)

could be enveloped inside a try/except block that rises an exception with self.urlconf_module string in it

Change History (4)

comment:1 by Marco De Paoli, 14 years ago

Cc: Marco De Paoli added

comment:2 by Carl Meyer, 14 years ago

Resolution: fixed
Status: newclosed

In [15566]:

[1.2.X] Fixed #15343 -- Added import of handler500 and handler404 in URLconf for contrib.auth tests, so that other configuration errors that cause test failures aren't masked by 'missing handler500' errors.

comment:3 by Carl Meyer, 14 years ago

No fix is needed in trunk, because in trunk URLconfs are no longer required to import handler500 and handler404.

comment:4 by afitzpatrick, 14 years ago

Cc: afitzpatrick added
Note: See TracTickets for help on using tickets.
Back to Top