Django

Code

Ticket #7871 (closed: fixed)

Opened 4 months ago

Last modified 4 months ago

No trailing slash in url causes TypeError with mod_wsgi

Reported by: gsf@breaksalot.org Assigned to: mtredinnick
Milestone: Component: Uncategorized
Version: SVN Keywords:
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

My Apache config includes the following line:

WSGIScriptAlias /testing /var/www/testing/django.wsgi

and my django.wsgi looks like this:

import os, sys

path = '/var/www'
if path not in sys.path:
    sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'testing.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

http://example.com/testing/ displays correctly, but http://example.com/testing (without the trailing slash) produces the following error:

Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response
  78.                     request.path_info)

Exception Type: TypeError at /testing
Exception Value: 'NoneType' object is not iterable

Attachments

Change History

07/21/08 14:04:14 changed by mtredinnick

  • owner changed from nobody to mtredinnick.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

07/21/08 14:05:25 changed by mtredinnick

  • stage changed from Unreviewed to Accepted.

Gaargh... I used to handle this and then I removed it to fix another bug (forgetting why it was there originally). When I fix it this time, it's definitely getting a comment! Thanks for the clear report.

07/21/08 17:13:57 changed by mtredinnick

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

(In [8032]) Fixed #7871 -- Added some more bullet-proofing in PATH_INFO determination, since Django would like it to at least contain a '/' (rather than being an empty string).

07/21/08 17:15:01 changed by mtredinnick

If you can still reproduce this problem, please reopen, but it would be helpful if you could also print what Django thinks self.path and self.path_info are at that point in the process. I'm fairly sure [8032] is the sufficient, though (and shouldn't harm other cases).

07/21/08 18:52:37 changed by gsf

That fixes it for me. Thanks!


Add/Change #7871 (No trailing slash in url causes TypeError with mod_wsgi)




Change Properties
Action