[uWSGI] nginx+uwsgi problem: Can't set empy SCRIPT_NAME param

Roberto De Ioris roberto at unbit.it
Wed Jul 7 11:55:32 CEST 2010


Il giorno 06/lug/2010, alle ore 23.35, Andrey Petrov ha scritto:

> The problem can be recreated by doing:
> 
> return redirect(url('/'))
> 
> With SCRIPT_NAME being "/", the URL that url('/') generates is '//'. This makes redirect('//') get confused and do infinite redirects.
> 
> A workaround is to always use absolute (qualified) urls, such as:
> 
> return redirect(url('/', qualified=True))
> 
> Or even:
> 
> return redirect('/')
> 
> Works too.
> 
> - Andrey
> 
> On Mon, Jul 5, 2010 at 12:31 AM, Roberto De Ioris <roberto at unbit.it> wrote:


Hi Andrey, i have managed to reproduce the problem, and i have modified the SCRIPT_NAME handling of the wsgi
core.

First of all the PEP 333 says that if the app is mounted in the root, SCRIPT_NAME can be (read: can be) empty (but not undefined).

So for me 

SCRIPT_NAME  ""

and 

SCRIPT_NAME "/"

are two different beasts

Someone is against this statement ?

Having said that, SCRIPT_NAME "" and "/" will map to the same app internally (the default app 0), but dynamic apps
can be defined even with an empty SCRIPT_NAME 

This will maintain backward compatibility and allow pylons apps to work out of the box (i hope)

Please clone the current mercurial repository, and retry in DynamicApps mode and with  --paste defining SCRIPT_NAME as ""
(paste wants a SCRIPT_NAME defined). If both works flawlessly i will backport this modification to the stable versions.

Thanks for your support

--
Roberto De Ioris
http://unbit.it
JID: roberto at jabber.unbit.it



More information about the uWSGI mailing list