Django doesn't work when called from a subdirectory using (Fast)CGI
|Reported by:||Andreas Kloeckner <inform@…>||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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 Changed 6 years ago by Andreas Kloeckner <inform@…>
- Cc inform@… added
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:2 Changed 6 years ago by Simon Greenhill
- milestone set to 1.0 alpha
- Triage Stage changed from Unreviewed to Accepted
comment:4 Changed 6 years ago by Andreas Kloeckner <inform@…>
- Summary changed from Django doesn't work when called from a subdirectory (Fast)CGI to Django doesn't work when called from a subdirectory using (Fast)CGI
comment:6 Changed 6 years ago by mtrichardson
- Resolution set to worksforme
- Status changed from new to closed