Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#7550 closed (worksforme)

Django doesn't work when called from a subdirectory using (Fast)CGI

Reported by: Andreas Kloeckner <inform@…> Owned by: nobody
Component: HTTP handling Version: dev
Severity: Keywords:
Cc: inform@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If a CGI calls django with an empty PATH_INFO (as may happen if the user only gives the script name, but nothing following it), Django dies with the following, opaque error message:

Traceback:
File "/sparc_soft/www.dam/htdocs/scicomp/pool/lib/python2.5/site-packages/django/core/handlers/base.py" 
in get_response
  73.             callback, callback_args, callback_kwargs = 
resolver.resolve(request.path)

Exception Type: TypeError at 
Exception Value: unpack non-sequence

This is the first problem, and it's due to the fact that if the request path does not match the resolver's self.regex, RegexURLResolver.resolve will simply return None, and the above tuple unpacking fails.

The second problem is that a few lines above the line in the traceback, the RegexURLResolver gets initialized with a "/" regex, and there's no user-facing way of changing that.

I fixed it for myself by simply feeding the resolver '/' if the path is empty. I'd prefer if there was a workable solution in Django by default.

Change History (7)

comment:1 by Andreas Kloeckner <inform@…>, 16 years ago

Cc: inform@… added

comment:2 by Simon Greenhill, 16 years ago

milestone: 1.0 alpha
Triage Stage: UnreviewedAccepted

comment:3 by Marc Garcia, 16 years ago

milestone: 1.0 alpha1.0

According to ticket organization defined in http://code.djangoproject.com/wiki/VersionOneRoadmap#how-you-can-help 1.0 alpha tickets should be just features in the Must have (http://code.djangoproject.com/wiki/VersionOneRoadmap#must-have-features) list.

As bug, it should be fixed before 1.0 milestone.

comment:4 by Andreas Kloeckner <inform@…>, 16 years ago

Summary: Django doesn't work when called from a subdirectory (Fast)CGIDjango doesn't work when called from a subdirectory using (Fast)CGI

On a related note, the admin login form, when run from a subdirectory, redirects to /admin, ignoring any prefixes it may have been given. Likewise, the admin logout link points to /admin/logout, even if the real page is at /prefix/admin/logout.

comment:5 by Andrew Stoneman, 16 years ago

Component: UncategorizedHTTP handling

comment:6 by mtrichardson, 16 years ago

Resolution: worksforme
Status: newclosed

comment:7 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

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