Opened 19 years ago

Closed 18 years ago

#1515 closed enhancement (wontfix)

Injecting into database exceptions is more portable than copying exceptions

Reported by: ianb@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: dev
Severity: normal Keywords:
Cc: ianb@… Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In django.core.db.init exceptions like DatabaseError are copied in from "the" database. This means only one database backend can be supported at any one time.

An alternate way to handle this is to inject a superclass into the database exceptions. sqlapi.exceptions is an example of this technique: http://svn.sqlobject.org/sqlapi/trunk/sqlapi/exceptions.py

Change History (3)

comment:1 by Michael Radziej <mir@…>, 18 years ago

Component: Admin interfaceDatabase wrapper
Triage Stage: UnreviewedDesign decision needed

comment:2 by Malcolm Tredinnick, 18 years ago

The only thing preventing me from saying this is a really good idea is whether it's sensible Python practice. Somebody (me?!) needs to do some research about whether injecting extra base classes like this is frowned on. I suspect it won't work in general (e.g. C-wrapped classes), but I don't know.

If we can guarantee it works for all database exceptions, then it's a good idea.

comment:3 by Malcolm Tredinnick, 18 years ago

Resolution: wontfix
Status: newclosed

We can't use this. It is not possible to assign to __bases__ in new-style classes, every exception class should be derived from Exception and in Python 2.5, Exception became a new-style class. So the method touted in the above link won't work in 2.5.

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