Code

Opened 8 years ago

Closed 7 years ago

#1515 closed enhancement (wontfix)

Injecting into database exceptions is more portable than copying exceptions

Reported by: ianb@… Owned by: adrian
Component: Database layer (models, ORM) Version: master
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: UI/UX:

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

Attachments (0)

Change History (3)

comment:1 Changed 7 years ago by Michael Radziej <mir@…>

  • Component changed from Admin interface to Database wrapper
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 7 years ago by mtredinnick

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 Changed 7 years ago by mtredinnick

  • Resolution set to wontfix
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.