url.rewrite-once =(
"^/(.*)$" => "/run.py/$1",
)
When i use web.changequery, it includes /run.py in the changed query.
For example when i am at url /hello and call web.changequery
(m="edit"), it gives
/run.py/hello?m=edit
instead of
/hello?m=edit
I think it is because web.changequery addes web.ctx.homepath to the
web.ctx.path before changing the query.
any workarounds?
Yes, I think you can use lighttpd to set the environment variable
REAL_SCRIPT_NAME to include run.py and then web.py should strip it out
How to set environment variables from lighttpd?
I tried setting REAL_SCRIPT_NAME by executing
os.environ['REAL_SCRIPT_NAME'] = "/run.py"
But it doesnt work.
web.py doesnt strip anything in setting homepath. This is the code,
which sets ctx.homepath and ctx.path
ctx.homepath = os.environ.get('REAL_SCRIPT_NAME', env.get
('SCRIPT_NAME', ''))
ctx.path = env.get('PATH_INFO')
# http://trac.lighttpd.net/trac/ticket/406 requires:
if env.get('SERVER_SOFTWARE', '').startswith('lighttpd/'):
ctx.path = lstrips(env.get('REQUEST_URI').split('?')[0],
os.environ.get('REAL_SCRIPT_NAME', env.get
('SCRIPT_NAME', '')))
However setting REAL_SCRIPT_NAME to "" solved the problem.
btw, http://trac.lighttpd.net/trac/ticket/406 is
PHP SCRIPT_NAME, PATH_INFO, PHP_SELF and others improperly
converted to lowercase
What is the relation between the code and the ticket#406? some typo?
I've already answered this whole thing. Try searching the group. :-)
Sam wrote:
> Alex K wrote:
> > Sure I can but how do I manage to setup lighttpd so that I don't have
> > to rewrite the url mapping.
>
> Well web.py uses web.ctx.home to figure out where things are, and this
> is calculated from the environmental variable SCRIPT_NAME, which can be
> overridden with REAL_SCRIPT_NAME, so for true hackery:
>
> fastcgi.server += ( "/webtest.py" => ( (
> "socket" => "/tmp/fastcgi.socket",
> "bin-path" => "/patch/to/webpy/app.py",
> "max-procs" => 1,
> # Stop 404s if not in docroot
> "check-local" => "disable",
> "bin-environment" => (
> # Mount location - note missing trailing '/'
> "REAL_SCRIPT_NAME" => "/myapp1"
> ),
> ) ) )
>
> I tested this on the latest svn tree, although from brief inspection it
> looks like it'll hold on 0.1xy (production) too.
>
> > I tried to play with the docroot option of fastcgi.server but I get a
> > webpy not found. Looking into the logs show that web.py does not take
> > into account the docroot option.
>
> To stop that you need to use "check-local" => "disable" in your fastcgi
> settings. That way lighttpd won't check to see if the file exists
> first. I included in the above example.
> See: http://trac.lighttpd.net/trac/wiki/Docs%3AModFastCGI#toc3
>
> Sam.
>>
>> Well web.py uses web.ctx.home to figure out where things are, and
>> this
>> is calculated from the environmental variable SCRIPT_NAME, which
>> can be
>> overridden with REAL_SCRIPT_NAME, so for true hackery:
>>
>> fastcgi.server += ( "/webtest.py" => ( (
>> "socket" => "/tmp/fastcgi.socket",
>> "bin-path" => "/patch/to/webpy/app.py",
>> "max-procs" => 1,
>> # Stop 404s if not in docroot
>> "check-local" => "disable",
>> "bin-environment" => (
>> # Mount location - note missing trailing '/'
>> "REAL_SCRIPT_NAME" => "/myapp1"
>> ),
>> ) ) )
>>
Thanks.