Django

Code

Ticket #10678 (closed: duplicate)

Opened 1 year ago

Last modified 1 year ago

Confusing error when django.root has a trailing slash

Reported by: tallfred Assigned to: nobody
Milestone: 1.2 Component: Core framework
Version: SVN Keywords: django.root mod_python
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

rick.diff (0.7 kB) - added by tallfred on 03/31/09 12:30:53.
patch to correct bad configurable values
django-10678.diff (0.6 kB) - added by Axis_of_Entropy on 08/05/09 22:09:40.
Alternative patch raising ValueError? when a bad django.root is configured

Change History

03/31/09 12:30:53 changed by tallfred

  • attachment rick.diff added.

patch to correct bad configurable values

04/02/09 10:03:48 changed by jacob

  • needs_better_patch changed.
  • needs_docs changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • milestone set to 1.1.

04/03/09 15:13:32 changed by jacob

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

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.

08/05/09 22:06:41 changed by Axis_of_Entropy

  • keywords set to django.root mod_python.
  • status changed from closed to reopened.
  • resolution deleted.
  • milestone changed from 1.1 to 1.2.

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.

08/05/09 22:09:40 changed by Axis_of_Entropy

  • attachment django-10678.diff added.

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

08/05/09 23:02:18 changed by mtredinnick

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

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.


Add/Change #10678 (Confusing error when django.root has a trailing slash)




Change Properties
Action