[Web-SIG] wsgiorg.routing_args and original SCRIPT_NAME

Manlio Perillo manlio_perillo at libero.it
Thu Jan 24 15:58:19 CET 2008


Sven Berkvens-Matthijsse ha scritto:
>> Phillip J. Eby ha scritto:
>>> At 03:22 PM 1/24/2008 +0100, Manlio Perillo wrote:
>>>> Let's suppose that the request uri is "/example/login/".
>>>>
>>>> For the main application, SCRIPT_NAME is "/example".
>>>> For the application at "/login", SCRIPT_NAME is "/example/login".
>>>>
>>>> My problem is that I want, in the page generated by "login" application,
>>>> return an anchor in the form "/example/logout/".
>>>>
>>>> The usual solution is to do environ['SCRIPT_NAME'] + '/logout', but this
>>>> will return "/example/login/logout/", and not "/example/logout/".
>>>>
>>>> This seems to be not possible with the current specifications, since the
>>>> "original" SCRIPT_NAME is lost.
>>>>
>>>> What is the best solution?
>>>>
>>>> 1) Do not change SCRIPT_NAME, and instead add a wsgiorg.consumed_path, a
>>>>     list.
>>>>
>>>>     This means that the request uri recostruction must be changed:
>>>>     SCRIPT_NAME = SCRIPT_NAME + '/'.join(wsgiorg.consumed_path)
>>>>
>>>> 2) Store a wsgiorg.original_script_name, with the value seen by the
>>>>     routing application.
>>>>
>>>> 3) Simply don't change SCRIPT_NAME and PATH_INFO.
>>>>     However I usually need the updated PATH_INFO.
>>> 4) Use a relative link, with href="logout".
>>>
>> But since the base url is "/example/login/", this relative link is 
>> resolved to "/example/login/logout/".
> 
> In that case, use href="../logout/".
> 


I would not call this a solution!
It's only a workaround.



Manlio Perillo




More information about the Web-SIG mailing list