lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


	Hi,

>     http2 = clone(http)
>     http2.PROXY = "whatever"
>
> the implementation will still see the first value of PROXY, unless the
> "clone" function is magic. I believe this is a problem, or is it?
	I think this is another problem.  I was saying that with the
Virtual Environment you can do that.  In fact, we are doing this all
the time with CGILua: each new request has its own environment which
inherits the globals from the original environment.  I just checked it!
Your example will be:

require"luasocket"
socket.http.PORT = 8080
...

	This value of PORT (the test didn't work changing the PROXY variable
so I decided to use PORT) will affect only this script and not any other one!
Soon we'll release Virtual Environment as a separate library (it does only
need documentation).
	Note that the main script running will create a virtual environment
before executing the above test:

local script, err = loadfile ("script.lua")
local f = venv (script)
f ()

	Tomas