On Sat, Dec 26, 2009 at 6:07 PM, Chris Withers <ch...@simplistix.co.uk>wrote:

> Graham Dumpleton wrote:
> >
> >> I also added a <pre>{{request}}</pre> to the base.html of the django
> >> app. Here's the output of the request's SCRIPT_NAME for various urls:
> >>
> >> /studio   - u''
> >> /studio/  - u'/studio'
> >> /test     - '/test'
> >> /test/    - '/test/'
> >
> > Hmmm, that would suggest that it is Django that is changing it for
> > some reason.
>
> I believe it's a bug in Django:
>
>
> http://code.djangoproject.com/browser/django/tags/releases/1.1.1/django/core/handlers/base.py#L204
>
>
Inline is easier to see:

    script_url = environ.get('SCRIPT_URL', u'')
    if not script_url:
        script_url = environ.get('REDIRECT_URL', u'')
    if script_url:
        return force_unicode(script_url[:-len(environ.get('PATH_INFO',
''))])
    return force_unicode(environ.get('SCRIPT_NAME', u''))

Line 204 is the one that returns a modified script_url based on what's in
PATH_INFO.

 [snip]

> The problem is when PATH_INFO is empty, as it is in the top case. Python
> has no notion of positive or negative zero (;-)) so we end up returning
> script_url[:0]...
>
> Now, I'm really curious that Karen says this works for her. Karen, can
> you have a look at what's different about your apache setup, as I can't
> see how this would ever correctly work for the "root url without the
> slash" case.
>

In my case, environ.get('SCRIPT_URL', u'') and environ.get('REDIRECT_URL',
u'') both return empty.  So I don't get to line 204, I go to line 205, which
returns the correct value. I don't know what's different about my Apache
setup to result in that difference, this is a pretty bare-bones virtual host
I have set up for testing.

Since rewrites were mentioned earlier perhaps it's significant that this
Apache setup doesn't have mod_rewrite enabled.

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to