Dear Django developers,

The code importing urls.py has a flaw that is easy to fix but has the
potential to cause a lot of frustration especially for inexperienced
developers -- which I do hope will try out Django in large numbers
soon :)

The problem is this: When importing urls.py _any_ exception is caught
and then re-raised as an ImproperlyConfigured exception, not giving
the traceback. This was not that big of an issue until we started to
tell people to put admin.autodiscover() in their urls.py. Now a lot of
code can get executed from there and if you get an exception you have
no clue where it originated. This is especially true if you port a
large project to 1.0. I, at least, keep running into it ... but don't
take my word for it. I just found a thread [1] on django users on the
issue (#7524). To cite Karen Tracey:

> I agree that the way ImproperlyConfigured is swallowing traceback
> information is not good.  It may not have been much of an issue before, but
> with admin.autodiscover() now recommended to be placed in urls.py, we are
> seeing a lot of confusion resulting from real errors in admin.py being
> hidden and the message seeming to imply something is wrong in urls.py. I
> don't have time right now, but you might want to search the tracker and see
> if there are any already-logged tickets about this less-than-helpful
> behavior and if not, open one.

Luckily the solution is quite easy. Just let the exception bubbly up
(see my patch [2]). It's changing nothing. We don't add any value by
wrapping the exception in an ImproperlyConfigured one because we do
not know anything about the error in this particular case.

Django swallows exceptions at multiple places and it is clear that we
need a unified solution. But in this case I think it's special. The
code does the wrong thing here.

Cheers,

Jonas

P.S.: I should have brought this up here earlier instead of causing a
somewhat lengthy discussion on IRC, sorry for that. I hope James
doesn’t hate me after this ;)

[1] 
http://groups.google.de/group/django-users/browse_thread/thread/487d8c3c28eee5f8
[2] 
http://code.djangoproject.com/attachment/ticket/7524/01-url-import-exception.patch
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to