Opened 8 years ago

Closed 4 years ago

#8238 closed Uncategorized (fixed)

django/db/__init__.py assumes it is loaded from the filesystem

Reported by: Guido van Rossum <guido@…> Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: bhuztez@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

There is code in the django.db package init.py that lists the available db backends. Unfortunately this code uses os.listdir() on a directory derived from file, and when loaded from a zip archive, this doesn't work. I have a quick hack that works around this, but perhaps there's a better way.

Attachments (2)

db.diff (1.0 KB) - added by Guido van Rossum <guido@…> 8 years ago.
patch
load-backend-pep-302.diff (1.2 KB) - added by bhuztez 4 years ago.
taken from pep-302.5.diff for #596

Download all attachments as: .zip

Change History (9)

Changed 8 years ago by Guido van Rossum <guido@…>

Attachment: db.diff added

patch

comment:1 Changed 8 years ago by Malcolm Tredinnick

milestone: 1.0
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by Guido van Rossum <guido@…>

ping?

comment:3 Changed 8 years ago by Malcolm Tredinnick

The ticket is marked as 1.0. Not 1.0-beta. We addressed those first. It's still open. We'll get to it. :-)

comment:4 Changed 8 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [8424]) Fixed #8238 -- If an invalid database backend is mentioned in settings and the
environment doesn't support os.listdir(), we crashed whilst trying to construct
the friendly error message. This was not so friendly.

This patch handles that case (which occurs in real life in Google App Engine).
Patch from Guido van Rossum.

comment:5 Changed 5 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

Changed 4 years ago by bhuztez

Attachment: load-backend-pep-302.diff added

taken from pep-302.5.diff for #596

comment:6 Changed 4 years ago by bhuztez

Cc: bhuztez@… added
Easy pickings: unset
Resolution: fixed
Severity: Normal
Status: closedreopened
Type: Uncategorized
UI/UX: unset

The load-backend-pep-302 patch use pkgutil.iter_modules instead of os.listdir to solve this.

comment:7 Changed 4 years ago by Ramiro Morales

Resolution: fixed
Status: reopenedclosed

Thabks for the contribution. Please don't reopen closed for bugs reported and fixed a long time ago with the intention of proposing new features, even when the topics are tightly related. It pollutes ticket history and overall bug tracker stats (e.g. lifetime of tickets)

Open another, new ticket for that.

Version 0, edited 4 years ago by Ramiro Morales (next)
Note: See TracTickets for help on using tickets.
Back to Top