Django, LiteSpeed Context / External App Config, and PATH_INFO

Discussion in 'CGI/Perl/Python' started by danofames, Jan 22, 2008.

  1. danofames

    danofames New Member

    First, I'm just getting started with LiteSpeed and enjoying the experience so far.

    I was able to get a Django application running by setting up the External App, and Context for '/' as described in these forums.

    When I did so, and tried to access the root of the site, http://mysite.com/, there would be an error similar to the one described in this ticket:
    http://code.djangoproject.com/ticket/3414

    Looking through the debug information, the PATH_INFO variable was not getting through to Django. One of the fixes on the ticket checks whether or not it is set, and if it's not, sets the an internal path variable to '/'. The error went away after applying that patch.

    I have no idea if this is an issue with LiteSpeed or Django, but I was curious if there was a setting in LiteSpeed that may be affecting the lack of PATH_INFO in Python's implementation of FastCGI. Nothing was apparent while poking around, so I'm assuming it's a quirk of the FastCGI libraries or Django's code, but I wanted to see if I could get more information.

    Thanks,
    dc
  2. mistwang

    mistwang LiteSpeed Staff

    Thanks for the update.
    Since there is no standard way to set PATH_INFO environment variable, some server set it for some application, some servers do not. The best way to fix it is to test PATH_INFO env in Python and set it to the desirable value if missing.
  3. danofames

    danofames New Member

    an approach that seems to work and doesn't involve changing Django core files is adding a middleware request class something like this:

    Code:
    class SetEmptyPathInfo(object): 
        def process_request(self, request): 
            if not request.path: 
                request.META['PATH_INFO'] = '/' 
                request.path = '/' 

Share This Page