Django

Code

Ticket #879 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

Error when loading malformed MIDDLEWARE_CLASSES path

Reported by: anonymous Assigned to: adrian
Milestone: Component: Core framework
Version: Keywords: middleware core
Cc: nslater@gmail.com Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

base.py.diff (1.0 kB) - added by Noah Slater on 11/22/05 13:32:08.
Patch

Change History

11/22/05 13:32:08 changed by Noah Slater

  • attachment base.py.diff added.

Patch

11/22/05 13:32:36 changed by Noah Slater

Attached is how I have patched it localy.

11/22/05 13:41:10 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

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

11/22/05 13:49:48 changed by anonymous

  • status changed from closed to reopened.
  • resolution deleted.

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

11/22/05 13:51:00 changed by Noah Slater

  • status changed from reopened to closed.
  • resolution set to fixed.

Fixed as I reopened. Heh.


Add/Change #879 (Error when loading malformed MIDDLEWARE_CLASSES path)




Change Properties
Action