#15946: Exceptions used for program logic db/utils.py load_backend
------------------------+----------------------------------------------
 Reporter:  sgronblo@…  |          Owner:  nobody
     Type:  Bug         |         Status:  new
Milestone:              |      Component:  Database layer (models, ORM)
  Version:  1.2         |       Severity:  Normal
 Keywords:              |   Triage Stage:  Unreviewed
Has patch:  0           |  Easy pickings:  0
------------------------+----------------------------------------------
 I noticed this problem when trying to figure out why one of my views
 wouldn't load. The problem there seems to be that it catches both
 ImportErrors and AttributeErrors in the same catch. I tried modifying the
 code to explode at when import_module calls __import__ instead but then
 Django stopped working.

 This is because of how db/utils.py's load_backend tries to determine if
 you have used a non-package-prefixed name when specifying your db backend.
 load_backend does this by blindly prefixing the provded backend name with
 django.db.backends and then importing it. If the import succeeds Django
 thinks you used the short name and if it fails Django thinks you specified
 the prefixed name.

 It would probably have been better to just check if the module name begins
 with django.db.backends or not instead of relying on import
 success/failure?

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15946>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to