Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#10678 closed (duplicate)

Confusing error when django.root has a trailing slash

Reported by: Rick Dean Owned by: nobody
Component: Core (Other) Version: dev
Severity: Keywords: django.root mod_python
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If using mod_python, and django.root has a trailing
slash, then some pages fail with a confusing "NoneType
is not iterable" error on line 82 of core/handlers/base.py
because request.path_info is None. The following patch
fixes it by silently truncating the configurable.

Also, can we please add double quotes around the value
of example django.root setting on
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/

Attachments (2)

rick.diff (708 bytes ) - added by Rick Dean 15 years ago.
patch to correct bad configurable values
django-10678.diff (645 bytes ) - added by Adam Vollrath 15 years ago.
Alternative patch raising ValueError when a bad django.root is configured

Download all attachments as: .zip

Change History (7)

by Rick Dean, 15 years ago

Attachment: rick.diff added

patch to correct bad configurable values

comment:1 by Jacob, 15 years ago

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:2 by Jacob, 15 years ago

Resolution: worksforme
Status: newclosed

I can't reproduce this problem with or without the patch. The fact that "some page fail" indicates that it's not something this cut and dry. Also, note that the lines following guard against an empty path_info (line 33) so just striping the slash won't change that.

I'm marking worksforme; please feel free to reopen if you find more information.

comment:3 by Adam Vollrath, 15 years ago

Keywords: django.root mod_python added
milestone: 1.11.2
Resolution: worksforme
Status: closedreopened

I can consistently induce a similar error by setting django.root to simply '/'. Here's the maddening Traceback:

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
    result = object(req)

  File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 230, in handler
    return ModPythonHandler()(req)

  File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 203, in __call__
    response = self.get_response(request)

  File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 115, in get_response
    return debug.technical_404_response(request, e)

  File "/usr/lib/python2.4/site-packages/django/views/debug.py", line 247, in technical_404_response
    tried = exception.args[0]['tried']

KeyError: 'tried'

I admit that setting django.root to '/' was a mistake, but this took me over an hour to track down. I'd like to help out others who might make the same mistake. I'll attach a patch that raises an exception when a bad django.root is used.

by Adam Vollrath, 15 years ago

Attachment: django-10678.diff added

Alternative patch raising ValueError when a bad django.root is configured

comment:4 by Malcolm Tredinnick, 15 years ago

Resolution: duplicate
Status: reopenedclosed

Duplicate of #9270. Anybody putting django.root = "/" hasn't read the documentation for how django.root is being used, by the way. It's never required.

comment:5 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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