Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#879 closed defect (fixed)

Error when loading malformed MIDDLEWARE_CLASSES path

Reported by: anonymous Owned by: Adrian Holovaty
Component: Core (Other) Version:
Severity: normal Keywords: middleware core
Cc: nslater@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If the settings file defines the middleware classes like this:

MIDDLEWARE_CLASSES = ('foo',)

The following code found in /core/handlers/base.py when calling load_middleware():

        for middleware_path in settings.MIDDLEWARE_CLASSES:
            try:
                dot = middleware_path.rindex('.')
                mw_module, mw_classname = middleware_path[:dot], middleware_path[dot+1:]
            except ValueError:
                raise exceptions.ImproperlyConfigured, '"%s" does not look like a middleware module' % (middleware_path)

will throw a ValueError when attempting the rindex('.') method call.

Attachments (1)

base.py.diff (1011 bytes ) - added by Noah Slater 19 years ago.
Patch

Download all attachments as: .zip

Change History (5)

by Noah Slater, 19 years ago

Attachment: base.py.diff added

Patch

comment:1 by Noah Slater, 19 years ago

Attached is how I have patched it localy.

comment:2 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(In [1355]) Fixed #879 -- Middleware loader now throws a better error for MIDDLEWARE_CLASSES value without a dot. Thanks, Noah Slater

comment:3 by anonymous, 19 years ago

Resolution: fixed
Status: closedreopened

No problem! The grammar of the error message in [1355] has been mangled however. :)

comment:4 by Noah Slater, 19 years ago

Resolution: fixed
Status: reopenedclosed

Fixed as I reopened. Heh.

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